Skip to content

Instantly share code, notes, and snippets.

@JohannesFischer
Last active October 6, 2015 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohannesFischer/295b202da73d607111bc to your computer and use it in GitHub Desktop.
Save JohannesFischer/295b202da73d607111bc to your computer and use it in GitHub Desktop.
AngularJS - extend controller
angular.module('MyApp').controller('MyController', ['$scope', function ($scope) {
$scope.data = [1, 2, 3];
$scope.action = function () {
console.log('surprise motherfucker!');
};
}]);
angular.module('MyApp').controller('MyControllerImpl', ['$scope', '$controller',
function ($scope, $controller) {
angular.extend(this, $controller('MyController', {$scope: $scope}));
$scope.anotherAction = function () {
console.log($scope.data);
};
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment