Reputation: 7557
This is my directive:
angApp.directive('stopPropagation', function () {
return {
restrict: 'A',
link: function (scope, elem, attr) {
console.log(elem);
$(elem).click(function (e) {
e.stopPropagation();
});
}
}
});
and this is my HTML code:
<form stop-propagation>
</form>
The console.log
is never fired. What am I missing?
Upvotes: 1
Views: 37
Reputation: 5758
You're missing ng-app
and ng-controller
to wire everything together:
<div ng-app="my-app" ng-controller="AppController">
<form stop-propagation>
{{message}}
</form>
</div>
See updated fiddle:
Upvotes: 1