mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-28 20:10:29 +00:00
docs(ng:submit): update docs example to not add empty items
This commit is contained in:
parent
c9f2b1eec5
commit
2090136dd8
1 changed files with 12 additions and 3 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in a new issue