Suppose I have a directive:
.directive('money', ['Service', function (Service) {
controller: ['$scope', '$element', '$attrs', '$parse', function (scope, cElement, attrs, $parse) {
scope.someValue=1;
scope.someFunction = function(){
console.writeline('money');
}
}
and there is a second directive:
.directive('cash', ['Service', function (Service) {
controller: ['$scope', '$element', '$attrs', '$parse', function (scope, cElement, attrs, $parse) {
scope.someValue=1;
scope.someFunction = function(){
console.writeline('cash');
}
}
As you can see, the only difference between the two directives is the content of one function. Thus, the ideal way would be to inherit the entire controller and shadow so thatsomeFunction
Is it possible to do something similar in angular, or should I leave two directives with such small differences?
szpic source
share