国产探花免费观看_亚洲丰满少妇自慰呻吟_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的使用實例,如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 商都县| 海淀区| 英山县| 西华县| 左贡县| 青州市| 来安县| 日喀则市| 遂溪县| 大英县| 察雅县| 静宁县| 报价| 论坛| 甘德县| 巴塘县| 鹤山市| 泗阳县| 江川县| 永福县| 邵武市| 聂荣县| 盱眙县| 青河县| 肇东市| 防城港市| 上栗县| 自贡市| 太湖县| 双峰县| 水城县| 肇州县| 乐昌市| 松滋市| 刚察县| 得荣县| 布尔津县| 博乐市| 红安县| 和顺县| 柘荣县|