码迷,mamicode.com
首页 > 其他好文 > 详细

angular笔记_6

时间:2017-12-20 20:10:27      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:data   index   charset   src   control   angular   gpo   dex   1.4   

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="hd" ng-controller="ctrl">
{{data}}
<hr/>
<ul>
<li ng-repeat="(k,v) in data" style="{{$first?‘color:red‘:‘‘;}}">
{{k}}名称:{{v.name}} 网址:{{v.url}}</li>
</ul>
<hr/>
<ul>
<li ng-repeat="(k,v) in data" style="{{$middle?‘color:red‘:‘‘;}}">
{{k}}名称:{{v.name}} 网址:{{v.url}}</li>
</ul>
<hr/>
<ul>
<li ng-repeat="(k,v) in data" style="{{$last?‘color:red‘:‘‘;}}">
{{k}}名称:{{v.name}} 网址:{{v.url}}</li>
</ul>
<hr/>
<ul>
<li ng-repeat="(k,v) in data" style="{{k==2?‘color:red‘:‘‘;}}">
{{k}}名称:{{v.name}} 网址:{{v.url}}</li>
</ul>
<hr/>
<ul>
<li ng-repeat="(k,v) in data" ng-if="$first" style="{{$first?‘color:red‘:‘‘;}}">
<span>{{k}}名称:{{v.name}} 网址:{{v.url}}</span>
</li>
<li ng-repeat="(k,v) in data" ng-if="$middle" style="{{$middle?‘‘:‘‘;}}">
<span >{{k}}名称:{{v.name}} 网址:{{v.url}}</span>
</li>
<li ng-repeat="(k,v) in data" ng-if="$last" style="{{$last?‘color:green‘:‘‘;}}">
<span >{{k}}名称:{{v.name}} 网址:{{v.url}}</span>
</li>
</ul>
<hr/>
<ul ng-repeat="v in arr track by $index">
{{$index}}{{v}}
</ul>

</div>

<script>
var m=angular.module(‘hd‘,[]);
m.controller(‘ctrl‘,[‘$scope‘,function($scope){
//数组对象
$scope.data=[{name:‘百度‘,url:‘baidu.com‘},
{name:‘新浪‘,url:‘sina.com‘},
{name:‘搜狐‘,url:‘souhu.com‘},
{name:‘博客‘,url:‘blog.com‘}
];
//数组
$scope.arr=[‘百度‘,‘新浪‘,‘搜狐‘,‘搜狐‘];

}]);
</script>
</body>
</html>

angular笔记_6

标签:data   index   charset   src   control   angular   gpo   dex   1.4   

原文地址:http://www.cnblogs.com/yewook/p/8075355.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!