angular.js - 在Angular开发中,为什么要选用ng-click而不用原生的click
淡淡烟草味
淡淡烟草味 2017-05-15 16:53:48
0
2
517

刚刚接触Angular,希望大神指点。

淡淡烟草味
淡淡烟草味

reply all(2)
大家讲道理

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-clickCoupled 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

Ty80

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!