diff options
Diffstat (limited to 'docs/content/cookbook/form.ngdoc')
| -rw-r--r-- | docs/content/cookbook/form.ngdoc | 16 | 
1 files changed, 14 insertions, 2 deletions
| diff --git a/docs/content/cookbook/form.ngdoc b/docs/content/cookbook/form.ngdoc index 6cd1d83a..1b5bf32b 100644 --- a/docs/content/cookbook/form.ngdoc +++ b/docs/content/cookbook/form.ngdoc @@ -18,6 +18,18 @@ allow a user to enter data.        };        this.state = /^\w\w$/;        this.zip = /^\d\d\d\d\d$/; + +      this.addContact = function() { +         this.user.contacts.push({type:'', value:''}); +      }; + +      this.removeContact = function(contact) { +        for ( var i = 0, ii = this.user.contacts.length; i < ii; i++) { +          if (contact === this.user.contacts[i]) { +            this.user.contacts.splice(i, 1); +          } +        } +      };      }    </script>    <div ng:controller="FormController" class="example"> @@ -34,7 +46,7 @@ allow a user to enter data.             ng:pattern="zip"  required><br/><br/>      <label>Phone:</label> -    [ <a href="" ng:click="user.contacts.$add()">add</a> ] +    [ <a href="" ng:click="addContact()">add</a> ]      <div ng:repeat="contact in user.contacts">        <select ng:model="contact.type">          <option>email</option> @@ -43,7 +55,7 @@ allow a user to enter data.          <option>IM</option>        </select>        <input type="text" ng:model="contact.value" required/> -       [ <a href="" ng:click="user.contacts.$remove(contact)">X</a> ] +       [ <a href="" ng:click="removeContact(contact)">X</a> ]      </div>      <hr/>      Debug View: | 
