Created
October 31, 2015 08:04
-
-
Save magnet88jp/5e783e649bb81f19fbec to your computer and use it in GitHub Desktop.
AngularJS extend
This file contains 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
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