AngularJS的一點學習筆記

來源:互聯網
上載者:User

標籤:css   bootstrap   button   ffffff   form   trap   rip   script   hello   

  ng-options="item.action for item in todos"

  ng-options運算式的基本形式, 形如 "<標籤> for <項目> in <數組>

 

  <option value="">(chosse one) </option>

 

  ng-options="item.id as item.action for item in todos"

  在表單的形式如<所選屬性>as <標籤> for <變數> in <數組>

 

  ng-options="item.action group by item.place for item in todos" 

  將對象進行分組

 

  使用無範圍的控制器

  

 1 <!DOCTYPE html> 2 <html lang="en" ng-app="iApp"> 3 <head> 4     <meta charset="UTF-8"> 5     <title>Document</title> 6     <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"> 7     <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap-theme.css"> 8     <script src="bower_components/angular/angular.js"></script> 9     <script>10         angular.module(‘iApp‘,[])11             .controller(‘topCtrl‘,function(){12                 this.dataValue=‘Hello,Adam‘;13                 this.reverseText=function(){14                     this.dataValue=this.dataValue.split("").reverse().join("");15                 }16             })17     </script>18 </head>19 <body >20     <div class="well" ng-controller="topCtrl as ctrl">21         <h4>Top level Controller</h4>22         <div class="input-group">23             <span class="input-group-btn">24                 <button class="btn btn-default" ng-click="ctrl.reverseText()">Reverse</button>25             </span>26             <input type="text" class="form-control" ng-model="ctrl.dataValue">27         </div>28     </div>    29 </body>30 </html>

當應用無作域的控制器時,運算式的格式化形如:<要應用的控制器> as <變數名>

然後在視圖中使用ctrl變數訪問資料和行為,類似這樣:<input.....ng-model="ctrl.dataValue">

 

AngularJS的一點學習筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.