Tuesday, March 28, 2017

Call a controller from another controller in the Angular 1 paradigm?

You probably don't need to. If you need to call a function in the other controller you can have that controller assign the function to something hanging off $scope, call it off $scope itself, and then call it off $scope in the second spot. Obviously the controller making the assignment has to get seen before the controller that is to use the thing hanging off $scope.

 
 

Addendum 3/29/2017: What is above isn't so good. It's probably best to use a common service to share code across two controllers.

No comments:

Post a Comment