I have a parent controller inside the first module and a "child" controller inside the second module. The second module has a dependancy to the first. I want my "child" controller to inherit the "parent" controller. But the problem is how to call the "parent" controller method.
For example:
SecondModule.controller("childBrowseCtrl", function($scope, $injector, $controller){
$injector.invoke(ParentBrowseCtrl, this, {$scope:$scope});
//this overrides the onedit function from parent
$scope.onEdit = function(){
console.log("from edit console");
//how do i make this work?
ParentBrowseCtrl.$scope.onEdit();
};
});
The html structure:
<html>
<head></head>
<body>
<div ng-view></div>
</body>
<script src="coreapp.js"></script>
<script src="mainapp.js"></script>
<script>
angular.bootstrap(document,["MainApp"]);
</script>
</html>
This may work:
var parentOnEdit = $scope.onEdit;
$scope.onEdit = function() {
parentOnEdit();
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With