docs(ng:submit): update docs example to not add empty items

This commit is contained in:
Vojta Jina 2011-11-24 21:25:04 -08:00 committed by Igor Minar
parent c9f2b1eec5
commit 2090136dd8

View file

@ -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>