Skip to content

Commit b6a0777

Browse files
matskomhevery
authored andcommitted
fix(ngController): fix indentation bug which causes example to mess up
1 parent c380736 commit b6a0777

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

src/ng/directive/ngController.js

+23-26
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,32 @@
3535
<doc:example>
3636
<doc:source>
3737
<script>
38-
function SettingsController() {
38+
function SettingsController1() {
3939
this.name = "John Smith";
4040
this.contacts = [
4141
{type: 'phone', value: '408 555 1212'},
4242
{type: 'email', value: 'john.smith@example.org'} ];
4343
};
4444
45-
SettingsController.prototype.greet = function() {
45+
SettingsController1.prototype.greet = function() {
4646
alert(this.name);
4747
};
4848
49-
SettingsController.prototype.addContact = function() {
49+
SettingsController1.prototype.addContact = function() {
5050
this.contacts.push({type: 'email', value: 'yourname@example.org'});
5151
};
5252
53-
SettingsController.prototype.removeContact = function(contactToRemove) {
53+
SettingsController1.prototype.removeContact = function(contactToRemove) {
5454
var index = this.contacts.indexOf(contactToRemove);
5555
this.contacts.splice(index, 1);
5656
};
5757
58-
SettingsController.prototype.clearContact = function(contact) {
58+
SettingsController1.prototype.clearContact = function(contact) {
5959
contact.type = 'phone';
6060
contact.value = '';
6161
};
6262
</script>
63-
<div ng-controller="SettingsController as settings">
63+
<div id="ctrl-as-exmpl" ng-controller="SettingsController1 as settings">
6464
Name: <input type="text" ng-model="settings.name"/>
6565
[ <a href="" ng-click="settings.greet()">greet</a> ]<br/>
6666
Contact:
@@ -79,29 +79,26 @@
7979
</div>
8080
</doc:source>
8181
<doc:scenario>
82-
it('should check controller', function() {
83-
expect(element('.doc-example-live div>:input').val()).toBe('John Smith');
84-
expect(element('.doc-example-live li:nth-child(1) input').val())
82+
it('should check controller as', function() {
83+
expect(element('#ctrl-as-exmpl>:input').val()).toBe('John Smith');
84+
expect(element('#ctrl-as-exmpl li:nth-child(1) input').val())
8585
.toBe('408 555 1212');
86-
expect(element('.doc-example-live li:nth-child(2) input').val())
86+
expect(element('#ctrl-as-exmpl li:nth-child(2) input').val())
8787
.toBe('john.smith@example.org');
8888
89-
element('.doc-example-live li:first a:contains("clear")').click();
90-
expect(element('.doc-example-live li:first input').val()).toBe('');
89+
element('#ctrl-as-exmpl li:first a:contains("clear")').click();
90+
expect(element('#ctrl-as-exmpl li:first input').val()).toBe('');
9191
92-
element('.doc-example-live li:last a:contains("add")').click();
93-
expect(element('.doc-example-live li:nth-child(3) input').val())
92+
element('#ctrl-as-exmpl li:last a:contains("add")').click();
93+
expect(element('#ctrl-as-exmpl li:nth-child(3) input').val())
9494
9595
});
9696
</doc:scenario>
9797
</doc:example>
98-
99-
100-
10198
<doc:example>
10299
<doc:source>
103100
<script>
104-
function SettingsController($scope) {
101+
function SettingsController2($scope) {
105102
$scope.name = "John Smith";
106103
$scope.contacts = [
107104
{type:'phone', value:'408 555 1212'},
@@ -126,7 +123,7 @@
126123
};
127124
}
128125
</script>
129-
<div ng-controller="SettingsController">
126+
<div id="ctrl-exmpl" ng-controller="SettingsController2">
130127
Name: <input type="text" ng-model="name"/>
131128
[ <a href="" ng-click="greet()">greet</a> ]<br/>
132129
Contact:
@@ -146,17 +143,17 @@
146143
</doc:source>
147144
<doc:scenario>
148145
it('should check controller', function() {
149-
expect(element('.doc-example-live div>:input').val()).toBe('John Smith');
150-
expect(element('.doc-example-live li:nth-child(1) input').val())
146+
expect(element('#ctrl-exmpl>:input').val()).toBe('John Smith');
147+
expect(element('#ctrl-exmpl li:nth-child(1) input').val())
151148
.toBe('408 555 1212');
152-
expect(element('.doc-example-live li:nth-child(2) input').val())
149+
expect(element('#ctrl-exmpl li:nth-child(2) input').val())
153150
.toBe('john.smith@example.org');
154151
155-
element('.doc-example-live li:first a:contains("clear")').click();
156-
expect(element('.doc-example-live li:first input').val()).toBe('');
152+
element('#ctrl-exmpl li:first a:contains("clear")').click();
153+
expect(element('#ctrl-exmpl li:first input').val()).toBe('');
157154
158-
element('.doc-example-live li:last a:contains("add")').click();
159-
expect(element('.doc-example-live li:nth-child(3) input').val())
155+
element('#ctrl-exmpl li:last a:contains("add")').click();
156+
expect(element('#ctrl-exmpl li:nth-child(3) input').val())
160157
161158
});
162159
</doc:scenario>

0 commit comments

Comments
 (0)