For example, clicking only makes some data modifications, and displays and hides some DOM
習慣沉默2017-05-15 16:54:43
With ng-click, you can set a variable and use the value of the variable to control the area you want to show or hide through ng-show.
For example:
xxxxx
// 对controller里的值操作
ng-click="isShow=!isShow"
xxxxxx
// 改变后的值作用在视图上
ng-show="isShow"
迷茫2017-05-15 16:54:43
The DOM operation in the link can be a mouse stroke or a more complicated effect. For simplicity, I try to use ng-click and write a function in the scope to call it
为情所困2017-05-15 16:54:43
The poster’s answer is that for click events at any time, only ng-click is used. There is no usage scenario that needs to be written in the link in the instruction.
It’s also not clear what exactly the poster is asking about. The only click thing in Angular is ngClick. In many cases, it is wrong to use the traditional addEventListener in the link function. You should also use ngClick in the template of the instruction.
In fact, traditional DOM operations are only required for events that do not require drag and drop