var superModule = angular.module("superModule", []);
superModule.directive("superman", function() {
return {
scope: {},
restrict: 'AE',
controller: function($scope) {
$scope.abilities = [];
this.addStrength = function() {
$scope.abilities.push("strength");
};
this.addSpeed = function() {
$scope.abilities.push("speed");
};
this.addLight = function() {
$scope.abilities.push("light");
};
},
link: function(scope, element, attrs) {
console.log('superman');
//element.addClass('btn btn-primary');
element.bind('mouseenter', function() {
console.log(scope.abilities);
});
}
}
});
superModule.directive("strength", function() {
return {
require: '^superman',
link: function(scope, element, attrs, supermanCtrl) {
console.log('strength');
supermanCtrl.addStrength();
}
}
});
superModule.directive("speed", function() {
return {
require: '^superman',
link: function(scope, element, attrs, supermanCtrl) {
console.log('spead');
supermanCtrl.addSpeed();
}
}
});
superModule.directive("light", function() {
return {
require: '^superman',
link: function(scope, element, attrs, supermanCtrl) {
console.log('light');
supermanCtrl.addLight();
}
}
});