Angularjs中ng-repeat-start与ng-repeat-end的用法实例介绍
ng-repeat-start与ng-repeat-end时AngularJS(1.2.x)扩展的,使用这两个指令可以灵活控制遍历形式。
例如:
index.html
<div class="uk-panel" ng-controller="UserCtrl"> <ul class="uk-list uk-list-striped"> <li ng-repeat-start="user in users"> {{user.name}} </li> <li ng-repeat-end> {{user.email}} </li> </ul> </div>
index.js
var myApp = angular.module('myApp', []); myApp.controller('UserCtrl', ['$scope', function($scope){ $scope.users = [ { name:'张三', email:'[email protected]' }, { name:'李四', email:'[email protected]' }, { name:'王五', email:'[email protected]' } ]; }]);
运行结果:
完整的实例代码
<!DOCTYPE html> <html lang="zh-CN" ng-app="app"> <head> <meta charset="utf-8"> <title>ng-repeat-start 与 ng-repeat-end的用法</title> <link rel="stylesheet" href="../bootstrap.min.css"> </head> <body> <h4>多行遍历的实现方式</h4> <ul ng-controller="PeopleController"> <li ng-repeat-start="person in people"> {{ person.name }} </li> <li>住在</li> <li> {{ person.city }} </li> <br ng-repeat-end> </ul> <script src="../angular.min.js"></script> <script> angular.module('app', []) .controller('PeopleController', ['$scope', function($scope) { $scope.people = [ {name: '张三', city: '广东'}, {name: '李四', city: '江西'}, {name: '王五', city: '东北'} ] }]) </script> </body> </html>
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
相关推荐
鸟菜小端前 2018-09-12
CrazyDogWang 2017-02-14
zbwroom 2016-09-23
youyouzouzou 2015-11-30
princejingyun 2013-01-30
Oranq 2013-09-24
闲听风月 2018-01-16
forthemyth 2017-09-18
codergirl 2017-07-06
Inuyasha 2017-01-21
forthemyth 2017-01-21
鸟菜小端前 2017-01-19
thesameguo 2016-12-31
DataCastle 2016-12-13
鸟菜小端前 2016-11-02
codergirl 2019-04-29
鸟菜小端前 2019-04-26
Inuyasha 2016-08-23
雅特岚蒂斯 2019-04-25