diff options
| author | Igor Minar | 2010-10-22 16:44:14 -0700 | 
|---|---|---|
| committer | Misko Hevery | 2010-10-23 14:22:54 -0700 | 
| commit | 04a4d8b061d98f46dc97fb550d388d248845b369 (patch) | |
| tree | 65ffa23fb4edf41438c091655be1f4f9536975f5 /src/directives.js | |
| parent | bbd87c9425ae984f632783b1f33f415ec1747ca6 (diff) | |
| download | angular.js-04a4d8b061d98f46dc97fb550d388d248845b369.tar.bz2 | |
adding ng:submit directive for use with forms
- allows for binding angular expressions to onsubmit events
- prevent default submit action (page reload)
Diffstat (limited to 'src/directives.js')
| -rw-r--r-- | src/directives.js | 19 | 
1 files changed, 19 insertions, 0 deletions
diff --git a/src/directives.js b/src/directives.js index 148e1f86..49f0343d 100644 --- a/src/directives.js +++ b/src/directives.js @@ -218,6 +218,25 @@ angularDirective("ng:click", function(expression, element){    };  }); + +/** + * Enables binding angular expressions to onsubmit events. + * + * Additionally it prevents the default action (which for form means sending the request to the + * server and reloading the current page). + */ +angularDirective("ng:submit", function(expression, element) { +  return function(element) { +    var self = this; +    element.bind('submit', function(event) { +      self.$tryEval(expression, element); +      self.$root.$eval(); +      event.preventDefault(); +    }); +  }; +}); + +  angularDirective("ng:watch", function(expression, element){    return function(element){      var self = this;  | 
