码迷,mamicode.com
首页 > Web开发 > 详细

AngularJS 表达式与ng-bind

时间:2016-05-08 23:57:12      阅读:349      评论:0      收藏:0      [点我收藏+]

标签:

初学 多看语法的具体表现  有助于理解 与实际应用

AngularJS 表达式

AngularJS 表达式写在双大括号内:{{ expression }}。

AngularJS 表达式把数据绑定到 HTML,这与 ng-bind 指令有异曲同工之妙。

AngularJS 将在表达式书写的位置"输出"数据。

AngularJS 表达式 很像 JavaScript 表达式:它们可以包含文字、运算符和变量。

实例 {{ 5 + 5 }} 或 {{ firstName + " " + lastName }}

1.数字

总价: {{ quantity * cost }}

2.字符串 

{{ firstName + " " + lastName }}

3.对象

{{ person.lastName }}

4.数组

{{ points[2] }}

------ng-bind-----相同的实现-----------------

ng-bind="quantity * cost"

ng-bind="firstName + ‘ ‘ + lastName"

ng-bind="person.lastName"

ng-bind="points[2]

AngularJS 表达式与ng-bind

标签:

原文地址:http://www.cnblogs.com/songtianen/p/5472280.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!