diff options
| author | Igor Minar | 2010-09-30 23:07:36 +0800 |
|---|---|---|
| committer | Misko Hevery | 2010-10-01 07:44:46 +0800 |
| commit | 8248e77a7b910bcbc71ca25c06bef44dd6712990 (patch) | |
| tree | 333b5b91e914a96f27b214bac3ef61c8d04e5b4d /src/directives.js | |
| parent | 0af763dcec8b9f6b17208ac58607cd1124382f63 (diff) | |
| download | angular.js-8248e77a7b910bcbc71ca25c06bef44dd6712990.tar.bz2 | |
'A' tag widget and ng:click propagation change
* added a widget for A (anchor) tag, that modifies the default behavior
and prevent default action (location change and page reload) for tags
with empty href attribute
* stopped event propagation for all ng:click handlers
Diffstat (limited to 'src/directives.js')
| -rw-r--r-- | src/directives.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/directives.js b/src/directives.js index 69648e31..4443cc9d 100644 --- a/src/directives.js +++ b/src/directives.js @@ -198,13 +198,22 @@ angularWidget("@ng:repeat", function(expression, element){ }; }); + +/* + * A directive that allows creation of custom onclick handlers that are defined as angular + * expressions and are compiled and executed within the current scope. + * + * Events that are handled via these handler are always configured not to propagate further. + * + * TODO: maybe we should consider allowing users to control even propagation in the future. + */ angularDirective("ng:click", function(expression, element){ return function(element){ var self = this; element.bind('click', function(event){ self.$tryEval(expression, element); self.$root.$eval(); - event.preventDefault(); + event.stopPropagation(); }); }; }); |
