Forked from exit99/OOP style directive controllers for Angular
Last active
August 29, 2015 14:08
-
-
Save NicoleY77/a45020ef41e6f58402cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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