我有控制器(比如BaseCtrl
),它附带了许多功能。我想将BaseCtrl
扩展到共享其某些功能的其他控制器,但是,我只需要一个或两个函数(而不是BaseCtrl
的所有函数)。我已经看过一些演示如何扩展控制器的帖子,但我想知道是否可以扩展特定的功能以及如何扩展它?
答案 0 :(得分:2)
扩展我的评论:
app.controller('parentCtrl', function($scope,$rootscope) {
$rootscope.myPerent = function () {
//your code
}
});
app.controller('childCtrl', function($scope,$rootscope) {
$scope.ourPerent = function () {
$rootscope.myPerent();
}
});