javascript - angularjs - controller inheritance calling parent -
i have parent controller inside first module , "child" controller inside second module. second module has dependancy first. want "child" controller inherit "parent" controller. problem how call "parent" controller method.
for example:
secondmodule.controller("childbrowsectrl", function($scope, $injector, $controller){ $injector.invoke(parentbrowsectrl, this, {$scope:$scope}); //this overrides onedit function parent $scope.onedit = function(){ console.log("from edit console"); //how make 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(); };
Comments
Post a Comment