Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to make base directive controllers that can be inherited in Angular.js
app.directive('upgrade1', function () {
return {
restrict: 'E',
templateUrl: "my_template.html",
scope: {
'info': '=info',
},
controller: 'upgrade1',
}
});
app.directive('upgrade2', function () {
return {
restrict: 'E',
templateUrl: "my_template.html",
scope: {
'info': '=info',
},
controller: 'upgrade2',
}
});
function baseCtrl ($scope, $rootScope, $timeout) {
$scope.penguins = "Black and White";
$rootScope.tigers = "Black and Orange";
$timeout(function () {
$scope.half_black_animals = $scope.penguins + $rootScope.tigers;
});
}
app.controller('upgrade1', function ($scope, $rootScope, $timeout) {
$injector.invoke(baseCtrl, this, {$scope:$scope, $rootScope:$rootScope, $timeout:$timeout});
});
app.controller('upgrade2', function ($scope, $rootScope, $timeout) {
$injector.invoke(baseCtrl, this, {$scope:$scope, $rootScope:$rootScope, $timeout:$timeout});
$scope.flamingos = "Pink Pink Pink";
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.