You must do this check in the event handler:
myApp.directive('myDirective', function() {
return {
restrict: 'A',
controller: function(scope, el, attrs) {
scope.$on('myEvent', function(ev,args) {
if(el.hasClass(args.class)){
el.css({left: '+=100'});
}
});
},
};
});
Then add the parameters to $ broadcast
$rootScope.$broadcast('myEvent',{class:'one'})
user2273266
source
share