Hi everyone, I already post this issue on Stack Overflow but nobody seems to be able to help me. So here I am.
Some actions in my Angular app require the user to be registered. If the user is not, we want to show him a "Register modal" and prevent the original action. Those actions can be triggered via ng-click or any other "click binding" directive (for example the 'modal-toggle' one). So I found this solution: http://stackoverflow.com/a/16211108/2719044 This is pretty cool but only works with ng-click. I first wanted to make the "terminal" property of the directive dynamic but couldn't manage to do it. So the idea was to set "terminal" to true and manually prevent default click action in the directive. Here is my DOM: <!-- This can work with terminal:true and scope.$eval(attrs.ngClick) (see example above) --> <div user-needed ng-click="myAction()">Do it !</div> <!-- This doesn't work. I can't manage to prevent the modal-toggle to be executed --> <div user-needed modal-toggle="my-modal-id-yey">Show yourself modal !</div> And my directive(s) (which don't work...) // First try (with terminal:true) app.directive('userNeeded', function() { return { priority: -100, terminal: true, restrict: 'A', link: function(scope, element, attrs) { element.bind('click', function(e) { if(isRegistered()) { // Here we do the action like scope.$eval or something } }); } }; }); // Second try (with stopPropagation) app.directive('userNeeded', function() { return { priority: -100 restrict: 'A', link: function(scope, element, attrs) { element.bind('click', function(e) { if(!isRegistered()) { e.stopPropagation(); } }); } }; }); ...And that's why I'm here. Any idea ? Thanks a lot. -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
