Link and controller

Time:2020-12-19

In angular, the link is executed after the controller

  1. How to reference controller’s function in link?

Suppose the controller defines a function
function A () {}
If you want to use this function in link, you need to use it

————Bind the function to $scope in the controller.
     $scope.A = A;
     
     You can get function a in link

Recommended Today

Monkey patch monkey patch programming method and its application in Ruby

What ismonkey patch (Monkey Patch)? In a dynamic language, functions are added and changed without modifying the source code. Purpose of using monkey patch:1. Additional function2. Function change3. Fix program errors4. Add a hook to execute some other processing while executing a method, such as printing logs, realizing AOP, etc,5. Cache, when the amount of […]