前端之家收集整理的这篇文章主要介绍了
angularjs之循环遍历,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<!DOCTYPE html> <html lang="en"> <head> <Meta charset="UTF-8"> <title></title> <script type="text/javascript" src="js/angular.min.js"></script> </head> <body> <div ng-app="hd" id="" ng-controller="ctrl"> <ul> <li ng-repeat="(k,v) in data track by $index"> <sapn ng-if="$first" style="color:red">{{k}} 名称:{{v.name}} 网址:{{v.url}}</sapn> <span ng-if="$middle">{{k}} 名称:{{v.name}} 网址:{{v.url}}</span> <span ng-if="$last" style="color: blue;">{{k}} 名称:{{v.name}} 网址:{{v.url}}</span> </li> </ul> </div> <script> var m = angular.module("hd",[]); m.controller("ctrl",["$scope",function($scope) { $scope.data = [{ name: '百度',url: 'http://baidu.com' },{ name: '腾讯',url: 'http://qq.com' },{ name:"新浪",url:"http://sina.com" }]; }]); </script> </body> </html>