angular 学习笔记(2) ng-repeat遍历json

视图:

<div ng-app="myApp" ng-controller="myCtrl"> 
<ul> <li ng-repeat="(k,v) in data"> //k定义的是列表的索引值,页面中也要输出 {{k}} 名称:{{v.name}} 网址:{{v.url}} </li>
</ul>
</div>
<hr/>

  

控制器代码部分

var app = angular.module('myApp',[]);
    	app.controller('myCtrl',function($scope){
    		 $scope.data = [
            {name:'成都人',url:'chengduren.com'},
            {name:'成都网',url:'chengduwang.com'},
            {name:'成都云',url:'chengduyun.com'},
            {name:'hdphp',url:'hdphp.com'},
            {name:'hdcms',url:'hdcms.com'},
        ];
    	});

  

posted @ 2017-10-23 16:55  斯丢皮德曼  阅读(345)  评论(0编辑  收藏  举报