diff options
| author | Vojta Jina | 2011-11-24 21:25:04 -0800 | 
|---|---|---|
| committer | Igor Minar | 2011-12-06 13:07:27 -0800 | 
| commit | 2090136dd8bf13022898e63a89a1b84245392d18 (patch) | |
| tree | c5a39f7fde07423bacb07aba8f9195b361a5440b /src | |
| parent | c9f2b1eec5e8a9eaf10faae8a8accf0b771096e0 (diff) | |
| download | angular.js-2090136dd8bf13022898e63a89a1b84245392d18.tar.bz2 | |
docs(ng:submit): update docs example to not add empty items
Diffstat (limited to 'src')
| -rw-r--r-- | src/directives.js | 15 | 
1 files changed, 12 insertions, 3 deletions
| diff --git a/src/directives.js b/src/directives.js index 54469ea7..17dd1531 100644 --- a/src/directives.js +++ b/src/directives.js @@ -500,14 +500,16 @@ angularDirective("ng:click", function(expression, element){            this.list = [];            this.text = 'hello';            this.submit = function() { -            this.list.push(this.text); -            this.text = ''; +            if (this.text) { +              this.list.push(this.text); +              this.text = ''; +            }            };          }        </script>        <form ng:submit="submit()" ng:controller="Ctrl">          Enter text and hit enter: -        <input type="text" ng:model="text"/> +        <input type="text" ng:model="text" name="text" />          <input type="submit" id="submit" value="Submit" />          <pre>list={{list}}</pre>        </form> @@ -517,6 +519,13 @@ angularDirective("ng:click", function(expression, element){           expect(binding('list')).toBe('list=[]');           element('.doc-example-live #submit').click();           expect(binding('list')).toBe('list=["hello"]'); +         expect(input('text').val()).toBe(''); +       }); +       it('should ignore empty strings', function() { +         expect(binding('list')).toBe('list=[]'); +         element('.doc-example-live #submit').click(); +         element('.doc-example-live #submit').click(); +         expect(binding('list')).toBe('list=["hello"]');         });       </doc:scenario>     </doc:example> | 
