为什么我们需要 ng-click? [英] Why do we need ng-click?

查看:19
本文介绍了为什么我们需要 ng-click?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular 应用使用 ng-click() 属性而不是 onclick 事件.

Angular apps use the ng-click() attribute rather than the the onclick event.

这是为什么?

推荐答案

ng-click 包含一个角度表达式.Angular 表达式在 Angular scope 的上下文中计算,它绑定到具有 ng-click 属性的元素或该元素的祖先.

ng-click holds an angular expression. Angular expressions are evaluated in the context of an Angular scope, which is bound to the element having the ng-click attribute or an ancestor of that element.

Angular 表达式语言不包含流控制语句,不能声明变量或定义函数.这些限制意味着模板只能访问控制器或指令提供的变量和运行函数.

The Angular expression language doesn't include flow control statements and can't declare variables or define functions. These limitations mean templates can only access variables and run functions made available by a controller or directive.

这篇关于为什么我们需要 ng-click?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆