$controller 继承

有的时候需要继承关系,来解决重复代码,通过$controller就可以解决

var app = angular.module('angularjs-starter', []); 
app.controller('ParentCtrl ', function($scope) {
// I'm the sibling, but want to act as parent
});
app.controller('ChildCtrl', function($scope, $controller) {
$controller('ParentCtrl', {$scope: $scope}); //This works
});

资料

AngularJS控制器继承自另一控制器

angularjs controller 继承

Last updated