1:angular js 表达式
HTML5 允许扩展的(自制的)属性,以 data- 开头。AngularJS 属性以 ng- 开头,但是您可以使用 data-ng- 来让网页对 HTML5 有效。
ng-init 指令初始化 AngularJS 应用程序变量。
表达式:把数据绑定到html。
angular js 表达式写在双大括号内{
{expression}}anjular js 表达式数据绑定到html与ng- bind指令相同
2:anjular js 数字
<div ng-app= "" ng-init= " quantity=1;cost=5 "> <p>总价: { { quantity * cost }}</p> </div> 结果相同 <div ng-app= "" ng-init= " quantity=1;cost=5 "> <p>总价: <span ng-bind= " quantity * cost "></span></p> </div>
3:Anjular js 字符串
<div ng-app= "" ng-init= " firstName='John';lastName='Doe' " > <p>姓名: { { firstName + " " + lastName }}</p> </div> 结果相同 <div ng-app= "" ng-init= " firstName='John';lastName='Doe' " > <p>姓名: <span ng-bind= " firstName + ' ' + lastName " ></span></p>
4;Angular js 对象
ng-init :进行数据初始化
<div ng-app= "" ng-init= " person={firstName:'John',lastName:'Doe'} " > <p>姓为: { { person.firstName }}</p> </div> <div ng-app= "" ng-init= " person={firstName:'John',lastName:'Doe'} " >
<p>姓为 <span ng-bind= " person.lastName "></span></p> </div>
</div>