How Can I Call A Function That Is In Another Controler (angular Js)
in ControllerOne $scope.displayReport = function( status ){ statusCkeck( status ) ; } statusCkeck() ; is in another controller -controllerTwo How can i call this function fr
Solution 1:
You should use a service instead to avoid muddying up the controllers with code that calls functions in other controllers. If you're sharing functions, just define them in a service and inject that service where needed.
angular.module('myApp', [])
.factory('myService', function() {
return {
sharedFunction: function(foo, bar) {
return foo + bar;
}
}
};
Post a Comment for "How Can I Call A Function That Is In Another Controler (angular Js)"