Skip to content

Instantly share code, notes, and snippets.

@magnet88jp
Created October 31, 2015 08:04
Show Gist options
  • Save magnet88jp/5e783e649bb81f19fbec to your computer and use it in GitHub Desktop.
Save magnet88jp/5e783e649bb81f19fbec to your computer and use it in GitHub Desktop.
AngularJS extend
var MyApp = angular.module('app', []);
MyApp.controller('PagerCtrl', ['$scope', function ($scope) {
$scope.firstAction = function () {
console.log('implement the first action');
};
$scope.secondAction = function () {
console.log('implement the second action');
};
}]);
MyApp.controller('mailListCtrl', ['$scope', '$controller', function ($scope, $controller) {
angular.extend(this, $controller('PagerCtrl', {$scope: $scope}));
$scope.secondAction = function () {
console.log('Override the second action provided by PagerCtrl controller');
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment