큰 앱을 만들기 위해 각도를 사용하고 컨트롤러에 대한 일반적인 방법이 있습니다. 실제로 이것을 수행하는 가장 좋은 방법은 있습니까?AngularJS 컨트롤러를 늘리십시오
app.controller('baseController', function($scope, $controller, appFactory) {
var $scope.foo = function() {
// Do something
}
});
app.controller('childController', function($scope, $controller, appFactory) {
// Here i extend or something like, the base controller
$controller('baseController', {$scope: $scope});
var $scope.bar = function() {
// Do a lot of things an then call foo
$scope.foo();
}
}):
이 방법은 내 컨트롤러의 $ 범위가 있어야하기 때문에 사용합니다.
일반적으로 일반적인 메소드는 제공자 (서비스, 팩토리, ...)에 있어야합니다. Angular는 "보기와 모델을 중재하는"얇은 컨트롤러를 중심으로 설계되었습니다. 좀 더 자세한 내용을 드릴 수 있다면 좀 더 구체적인 조언을 드릴 수 있습니다 – KayakDave
이 스레드를 참조하십시오 http://stackoverflow.com/questions/16539999/angular-extending-controller – user2923779