diff options
| author | Misko Hevery | 2011-11-08 17:40:52 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2011-11-14 20:31:15 -0800 | 
| commit | 9c0639437607a4fcea379bbaf610600d05d8a9b7 (patch) | |
| tree | 1ae90d93d0139f7791487fe814360904254d39cb /docs/content/cookbook | |
| parent | 085e3c611fd0cd48757702c50c67b551a00a0d38 (diff) | |
| download | angular.js-9c0639437607a4fcea379bbaf610600d05d8a9b7.tar.bz2 | |
chore(scenario tests): make scenario tests pass again
Diffstat (limited to 'docs/content/cookbook')
| -rw-r--r-- | docs/content/cookbook/advancedform.ngdoc | 29 | ||||
| -rw-r--r-- | docs/content/cookbook/form.ngdoc | 16 | 
2 files changed, 39 insertions, 6 deletions
diff --git a/docs/content/cookbook/advancedform.ngdoc b/docs/content/cookbook/advancedform.ngdoc index 19b8284f..e973e30f 100644 --- a/docs/content/cookbook/advancedform.ngdoc +++ b/docs/content/cookbook/advancedform.ngdoc @@ -34,7 +34,28 @@ detection, and preventing invalid form submission.       save: function() {         this.master = this.form;         this.cancel(); +     }, + +     addContact: function() { +       this.form.contacts.push({type:'', value:''}); +     }, + +     removeContact: function(contact) { +       for ( var i = 0, ii = this.form.contacts.length; i < ii; i++) { +         if (contact === this.form.contacts[i]) { +           this.form.contacts.splice(i, 1); +         } +       } +     }, + +     isCancelDisabled: function() { +       return angular.equals(this.master, this.form); +     }, + +     isSaveDisabled: function() { +       return this.myForm.$invalid || angular.equals(this.master, this.form);       } +     };     </script>     <div ng:controller="UserForm"> @@ -53,7 +74,7 @@ detection, and preventing invalid form submission.                ng:pattern="zip" required/><br/><br/>         <label>Contacts:</label> -       [ <a href="" ng:click="form.contacts.$add()">add</a> ] +       [ <a href="" ng:click="addContact()">add</a> ]         <div ng:repeat="contact in form.contacts">           <select ng:model="contact.type">             <option>email</option> @@ -62,10 +83,10 @@ detection, and preventing invalid form submission.             <option>IM</option>           </select>           <input type="text" ng:model="contact.value" required/> -          [ <a href="" ng:click="form.contacts.$remove(contact)">X</a> ] +          [ <a href="" ng:click="removeContact(contact)">X</a> ]         </div> -     <button ng:click="cancel()" ng:disabled="{{master.$equals(form)}}">Cancel</button> -     <button ng:click="save()" ng:disabled="{{myForm.$invalid || master.$equals(form)}}">Save</button> +     <button ng:click="cancel()" ng:disabled="{{isCancelDisabled()}}">Cancel</button> +     <button ng:click="save()" ng:disabled="{{isSaveDisabled()}}">Save</button>     </form>     <hr/> 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:  | 
