I am trying to catch all anchor clicks and play with href's. so i have written below directive
app.directive('a', function() {
return {
restrict: 'E',
link: function(scope, elem, attrs) {
if(attrs.ngClick || attrs.href === '' || attrs.href === '#'){
elem.on('click', function(e){
alert(attrs.href);
e.preventDefault();
});
}
}
};
})
i have tried giving this in my app.js as well as in MyCtrl.js files. where my module declartion is this way in myCtrl.js:
var AppControllers = angular.module('starter.controllers');
AppControllers
Its working in another ionic project. Not sure where i am going wrong. can someone help me?