是否有任何选项可以像这样放置$last ng重复结果<li class="active">Four</li>
而不是<li><a href="#">Four</a></li>
?我一直在尝试ng-if
,但不幸的是,它还没有给出好的解决方案:(
演示:http://codepen.io/anon/pen/bdvVRe
var app = angular.module('myapp', []);
app.controller('testController', function($scope) {
$scope.mymenu = ["one", "two", "three", "four"];
});
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myapp">
<div ng-controller="testController" class="container">
<strong>Expecting</strong>
<br />
<ol class="breadcrumb">
<li><a href="#">One</a></li>
<li><a href="#">Two</a></li>
<li><a href="#">Three</a></li>
<li class="active">Four</li>
</ol>
<hr />
<strong>Current result</strong>
<ol class="breadcrumb">
<li ng-repeat="menu in mymenu"><a href="#">{{menu}}</a></li>
</ol>
</div>
</div>
<li ng-repeat="menu in mymenu" ng-class="{active: $last}">
<a ng-if="!$last" href="#">{{menu}}</a>
<span ng-if="$last">{{menu}}</span>
</li>
演示:http://codepen.io/anon/pen/domYZL