国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

Angularjs中ng-repeat的簡單實例

2019-11-19 15:40:31
字體:
來源:轉載
供稿:網友

Angularjs中ng-repeat的簡單實例

第一個例子:使用ng-repeat最簡單的例子

<html ng-app="myApp"><head><title>angularjs-demo</title><script type="text/javascript" src="angular.min.js" charset="utf-8"></script></head><body ng-controller="ctrl"><table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr>  <th>學號</th>  <th>姓名</th>  <th>分數</th> </tr> <tr ng-repeat="item in items">  <td>{{item.id}}</td>  <td>{{item.name}}</td>  <td>{{item.score}}</td> </tr></table><script>  var app = angular.module('myApp',[]);  app.controller("ctrl",function($scope,$location){    $scope.items = getStu();  });    function getStu() {    return [{id:1010,name:'張三',score:50},{id:1011,name:'李四',score:60},{id:1012,name:'王五',score:80}];  }  </script></body></html>

第二個例子:添加過濾條件

<html ng-app="myApp"><head><title>angularjs-demo</title><script type="text/javascript" src="angular.min.js" charset="utf-8"></script></head><body ng-controller="ctrl"><table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr>  <th>學號</th>  <th>姓名</th>  <th>分數</th> </tr> <tr ng-repeat="item in items | filter:fscore">  <td>{{item.id}}</td>  <td>{{item.name}}</td>  <td>{{item.score}}</td> </tr></table><script>  var app = angular.module('myApp',[]);  app.controller("ctrl",function($scope,$location){    $scope.items = getStu();    $scope.fscore = function(e) {      return e.score>=60;    }  });    function getStu() {    return [{id:1010,name:'張三',score:50},{id:1011,name:'李四',score:60},{id:1012,name:'王五',score:80}];  }  </script></body></html>

以上就是AngularJs 中ng-repent的使用實例,如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 青浦区| 永嘉县| 铅山县| 平舆县| 元氏县| 芜湖县| 沂源县| 柞水县| 昌平区| 襄樊市| 潮州市| 榆中县| 大足县| 文昌市| 游戏| 永靖县| 青神县| 桂阳县| 陈巴尔虎旗| 斗六市| 广丰县| 洱源县| 金秀| 阿荣旗| 崇仁县| 望江县| 永泰县| 鹤山市| 陆丰市| 新蔡县| 武冈市| 巴塘县| 开鲁县| 隆安县| 佛教| 永城市| 鲁甸县| 巩留县| 体育| 怀集县| 德惠市|