欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

AngularJS表達(dá)式講解及示例代碼

 更新時間:2016年08月16日 16:13:24   投稿:lqh  
本文主要講解AngularJS表達(dá)式,這里整理了相關(guān)資料和提供示例代碼以及實現(xiàn)效果圖,有需要的小伙伴可以參考下

表達(dá)式用于應(yīng)用程序數(shù)據(jù)綁定到HTML。表達(dá)式都寫在雙括號就像{{表達(dá)式}}。表達(dá)式中的行為跟ng-bind指令方式相同。 AngularJS應(yīng)用表達(dá)式是純javascript表達(dá)式,并輸出它們被使用的數(shù)據(jù)在那里。

使用數(shù)字

<p>Expense on Books : {{cost * quantity}} Rs</p>

使用字符串

<p>Hello {{student.firstname + " " + student.lastname}}!</p>

使用對象

<p>Roll No: {{student.rollno}}</p>

使用數(shù)組

<p>Marks(Math): {{marks[3]}}</p>

例子

下面的例子將展示上述所有表達(dá)式。

testAngularJS.html 文件代碼如下:

<html>
<title>AngularJS Expressions</title>
<body>
<h1>Sample Application</h1>
<div ng-app="" ng-init="quantity=1;cost=30; student={firstname:'Mahesh',lastname:'Parashar',rollno:101};marks=[80,90,75,73,60]">
  <p>Hello {{student.firstname + " " + student.lastname}}!</p>  
  <p>Expense on Books : {{cost * quantity}} Rs</p>
  <p>Roll No: {{student.rollno}}</p>
  <p>Marks(Math): {{marks[3]}}</p>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
</body>
</html>

輸出

在Web瀏覽器打開textAngularJS.html??吹浇Y(jié)果如下:

以上就是對AngularJS 表達(dá)式的資料整理,后續(xù)繼續(xù)補充相關(guān)資料,謝謝大家對本站的支持!

相關(guān)文章

最新評論