angularjs - How to put $last ngRepeat result out of href? -
is there option put $last ng-repeat result <li class="active">four</li>
instead of <li><a href="#">four</a></li>
? have been trying ng-if
unfortunately did not give solution yet :(
demo: 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>
Comments
Post a Comment