angularjs 初体验 循环

<html ng-app>


<div id="myCarousel" class="carousel slide" ng-controller="CarouselCtrl">
		  <ol class="carousel-indicators">
			<li class="pointer{{ pic.class }}" data-target="#myCarousel" data-slide-to="{{ $index }}" ng-repeat="pic in pictures"></li>
		  </ol>
		  <!-- Carousel items -->
		  <div class="carousel-inner">
			<div class="item{{ pic.class }}" ng-repeat="pic in pictures">
				<img src="{{ pic.img }}" alt />
				<div class="carousel-caption">
				  <h4>{{ pic.title }}</h4>
				  <p>{{ pic.content }}</p>
				</div>
			</div>
		  </div>
		  <!-- Carousel nav -->
		  <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
		  <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
		</div>

<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
	<script type="text/javascript" src="../../js/angular.min.js"></script>

 

function CarouselCtrl($scope) {
		$scope.pictures = [];
		$scope.pictures.push({class: ' active', img: 'http://ww4.sinaimg.cn/mw690/51baa38egw1ehxxxx513j20xh0p0tqm.jpg', 
							  title: '徐家汇公园长廊漫步', content: '看那花枝招展的梅花,红艳艳的桃花,还有你的笑容'});
		$scope.pictures.push({class: '', img: 'http://ww4.sinaimg.cn/mw690/51baa38egw1eh0xxxxoj20xh0p0qn4.jpg', 
							  title: '徐家汇公园长廊漫步2', content: '看那花枝招展的梅花,红艳艳的桃花,还有你的笑容'});
		$scope.pictures.push({class: '', img: 'http://ww2.sinaimg.cn/mw690/51baa38egw1eh0rfxxxxdwj20xh0p0tog.jpg', 
							  title: '徐家汇公园长廊漫步2', content: '看那花枝招展的梅花,红艳艳的桃花,还有你的笑容'});
		$scope.pictures.push({class: '', img: 'http://ww4.sinaimg.cn/mw690/51baa38egw1ehxxxxmsj20xh0p0h9x.jpg', 
							  title: '徐家汇公园长廊漫步2', content: '看那花枝招展的梅花,红艳艳的桃花,还有你的笑容'});
		$scope.pictures.push({class: '', img: 'http://ww1.sinaimg.cn/mw690/51baa38egw1ehxxxxzcvj20xh0p0avz.jpg', 
							  title: '徐家汇公园长廊漫步2', content: '看那花枝招展的梅花,红艳艳的桃花,还有你的笑容'});
		$scope.pictures.push({class: '', img: 'http://ww4.sinaimg.cn/mw690/51baa38egw1eh0xxxxwpwj20xh0p0gri.jpg', 
							  title: '徐家汇公园长廊漫步2', content: '看那花枝招展的梅花,红艳艳的桃花,还有你的笑容'});
		$scope.pictures.push({class: '', img: 'http://ww2.sinaimg.cn/mw690/51baa38egxxxxditzozj21kw16hhdt.jpg', 
							  title: '徐家汇公园长廊漫步2', content: '看那花枝招展的梅花,红艳艳的桃花,还有你的笑容'});
	}

 

其他实例:

<div ng-init="names=['Jani','Hege','Kai']">

  <p>使用 ng-repeat 来循环数组</p>

  <ul>

    <li ng-repeat="x in names">

      {{ x }}

    </li>

  </ul>

<div>

 

<table>

      <tr><th>row number</th></tr>

      <tr ng-repeat="i in [1, 2, 3, 4, 5, 6, 7]"><td>{{i}}</td></tr>

</table>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值