diff options
| author | Matias Niemelä | 2013-05-22 22:37:42 -0400 | 
|---|---|---|
| committer | Misko Hevery | 2013-05-31 06:35:44 -0700 | 
| commit | b6a0777b2406d639f3cb1e9aa38f65f1f6008995 (patch) | |
| tree | 13daebb8b7ba0108dcdd89e8368deefa9c691785 /src | |
| parent | c38073667d81bdd3b6cdb24a11ff9bcd261d0441 (diff) | |
| download | angular.js-b6a0777b2406d639f3cb1e9aa38f65f1f6008995.tar.bz2 | |
fix(ngController): fix indentation bug which causes example to mess up
Diffstat (limited to 'src')
| -rw-r--r-- | src/ng/directive/ngController.js | 49 | 
1 files changed, 23 insertions, 26 deletions
| diff --git a/src/ng/directive/ngController.js b/src/ng/directive/ngController.js index be2f149f..289ee034 100644 --- a/src/ng/directive/ngController.js +++ b/src/ng/directive/ngController.js @@ -35,32 +35,32 @@     <doc:example>       <doc:source>        <script> -        function SettingsController() { +        function SettingsController1() {            this.name = "John Smith";            this.contacts = [              {type: 'phone', value: '408 555 1212'},              {type: 'email', value: 'john.smith@example.org'} ];            }; -        SettingsController.prototype.greet = function() { +        SettingsController1.prototype.greet = function() {            alert(this.name);          }; -        SettingsController.prototype.addContact = function() { +        SettingsController1.prototype.addContact = function() {            this.contacts.push({type: 'email', value: 'yourname@example.org'});          }; -        SettingsController.prototype.removeContact = function(contactToRemove) { +        SettingsController1.prototype.removeContact = function(contactToRemove) {           var index = this.contacts.indexOf(contactToRemove);            this.contacts.splice(index, 1);          }; -        SettingsController.prototype.clearContact = function(contact) { +        SettingsController1.prototype.clearContact = function(contact) {            contact.type = 'phone';            contact.value = '';          };        </script> -      <div ng-controller="SettingsController as settings"> +      <div id="ctrl-as-exmpl" ng-controller="SettingsController1 as settings">          Name: <input type="text" ng-model="settings.name"/>          [ <a href="" ng-click="settings.greet()">greet</a> ]<br/>          Contact: @@ -79,29 +79,26 @@        </div>       </doc:source>       <doc:scenario> -       it('should check controller', function() { -         expect(element('.doc-example-live div>:input').val()).toBe('John Smith'); -         expect(element('.doc-example-live li:nth-child(1) input').val()) +       it('should check controller as', function() { +         expect(element('#ctrl-as-exmpl>:input').val()).toBe('John Smith'); +         expect(element('#ctrl-as-exmpl li:nth-child(1) input').val())             .toBe('408 555 1212'); -         expect(element('.doc-example-live li:nth-child(2) input').val()) +         expect(element('#ctrl-as-exmpl li:nth-child(2) input').val())             .toBe('john.smith@example.org'); -         element('.doc-example-live li:first a:contains("clear")').click(); -         expect(element('.doc-example-live li:first input').val()).toBe(''); +         element('#ctrl-as-exmpl li:first a:contains("clear")').click(); +         expect(element('#ctrl-as-exmpl li:first input').val()).toBe(''); -         element('.doc-example-live li:last a:contains("add")').click(); -         expect(element('.doc-example-live li:nth-child(3) input').val()) +         element('#ctrl-as-exmpl li:last a:contains("add")').click(); +         expect(element('#ctrl-as-exmpl li:nth-child(3) input').val())             .toBe('yourname@example.org');         });       </doc:scenario>     </doc:example> - - -      <doc:example>       <doc:source>        <script> -        function SettingsController($scope) { +        function SettingsController2($scope) {            $scope.name = "John Smith";            $scope.contacts = [              {type:'phone', value:'408 555 1212'}, @@ -126,7 +123,7 @@            };          }        </script> -      <div ng-controller="SettingsController"> +      <div id="ctrl-exmpl" ng-controller="SettingsController2">          Name: <input type="text" ng-model="name"/>          [ <a href="" ng-click="greet()">greet</a> ]<br/>          Contact: @@ -146,17 +143,17 @@       </doc:source>       <doc:scenario>         it('should check controller', function() { -         expect(element('.doc-example-live div>:input').val()).toBe('John Smith'); -         expect(element('.doc-example-live li:nth-child(1) input').val()) +         expect(element('#ctrl-exmpl>:input').val()).toBe('John Smith'); +         expect(element('#ctrl-exmpl li:nth-child(1) input').val())             .toBe('408 555 1212'); -         expect(element('.doc-example-live li:nth-child(2) input').val()) +         expect(element('#ctrl-exmpl li:nth-child(2) input').val())             .toBe('john.smith@example.org'); -         element('.doc-example-live li:first a:contains("clear")').click(); -         expect(element('.doc-example-live li:first input').val()).toBe(''); +         element('#ctrl-exmpl li:first a:contains("clear")').click(); +         expect(element('#ctrl-exmpl li:first input').val()).toBe(''); -         element('.doc-example-live li:last a:contains("add")').click(); -         expect(element('.doc-example-live li:nth-child(3) input').val()) +         element('#ctrl-exmpl li:last a:contains("add")').click(); +         expect(element('#ctrl-exmpl li:nth-child(3) input').val())             .toBe('yourname@example.org');         });       </doc:scenario> | 
