AngularJS 表達(dá)式

表達(dá)式用于將應(yīng)用程序數(shù)據(jù)綁定到HTML。表達(dá)式寫在雙花括號內(nèi),例如{{expression}}中。表達(dá)式的行為類似于ngbind指令。AngularJS表達(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.htm

<html>
   <head>
      <title>AngularJS表達(dá)式</title>
   </head>
   
   <body>
      <h1>示例應(yīng)用程序</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 = "https://cdn.staticfile.org/angular.js/1.3.14/angular.min.js">
      </script>
      
   </body>
</html>
測試看看?/?

輸出結(jié)果

在網(wǎng)絡(luò)瀏覽器中打開文件testAngularJS.htm并查看結(jié)果。

圖片.png

丰满人妻一级特黄a大片,午夜无码免费福利一级,欧美亚洲精品在线,国产婷婷成人久久Av免费高清