Angularjs中ng-repeat-start與ng-repeat-end的用法實例介紹
更新時間:2016年12月31日 09:32:53 投稿:daisy
這篇文章主要給大家介紹了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:'zhangsan@gmail.com' }, { name:'李四', email:'lisi@123.com' }, { name:'王五', email:'wangwu@qq.com' } ]; }]);
運行結(jié)果:
完整的實例代碼
<!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>多行遍歷的實現(xiàn)方式</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>
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。
相關(guān)文章
利用VS Code開發(fā)你的第一個AngularJS 2應(yīng)用程序
這篇文章主要給大家介紹了關(guān)于利用VS Code如何開發(fā)你的第一個AngularJS 2應(yīng)用程序的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友下面來一起看看吧。2017-12-12Angular 利用路由跳轉(zhuǎn)到指定頁面的指定位置方法
今天小編就為大家分享一篇Angular 利用路由跳轉(zhuǎn)到指定頁面的指定位置方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08