大家讲道理2017-05-15 16:55:48
1. Because of ng-click
中解析的是AngularJs
的表达式
,而原生的click
只是单纯的运行JavaScript
’s code.
2. For expressions about AngularJS
, you can see here (need to circumvent the wall), or here (no need to circumvent the wall).
3.ng-click
Coupled with other commands, it can show its powerful capabilities.
4. Another problem is the scope of ng-click
它的作用域在声明它的那个控制器的作用域内,而原生click
. Its scope is within the scope of the controller where it is declared, while the scope of native click
is generally global.
5. I have written here a commonly used example portal, I hope it can be of some help to you. ng-click
PHP中文网2017-05-15 16:55:48
ng-click is a directive of angular, and the attribute value is an expression. It is an optimization of onclick. The functions it can achieve can also be achieved by onclick, but ng-click is more intelligent. For example, angular has already packaged it for you. The scope corresponding to ng-click, etc. But the scope of onclick needs to be set by yourself
For specific differences, please see the difference between ng-click and onclick here
I think it’s similar to the difference between jquery and native javascript