0

像这样:

<div class="item" ng-repeat="priority in priorities" ng-class="{active: {{$index}} == {{routeParams.priorityId - 1}} }"></div>

<a class="carousel-control left" ng-hide="!goals.length" href="#myCarousel" ng-click="changePriorityIdParam($index)" data-slide="prev">&lsaquo;</a>

app.controller("PriorityDetailController", function ($http, $scope, $location, $routeParams) {
    console.log("PriorityDetailController - priorityId: " + $routeParams.priorityId);
    getPriorityForPriorityId($http, $scope, $routeParams);

    $scope.changePriorityIdParam = function(index) {
        console.log("changePriorityIdParam() - index: " + index);
        $location.path('/priority/' + index);
        $location.replace();
    };
})
4

1 回答 1

0

不,这没有任何意义。你要复制哪个索引,第一个,最后一个,全部?你用那个旋转木马做错了什么。

在优先级集合上编写一个过滤器,它将获取您的活动元素。

或者是这样的:

$scope.changePriorityIdParam = function() {
    var index = 0;
    angular.forEach($scope.priorities, function ( priority, idx) {
        if ( priority == routeParams.priorityId - 1 ) {
            index = idx;
        }
    });
    console.log("changePriorityIdParam() - index: " + index);
    $location.path('/priority/' + index);
    $location.replace();
};
于 2013-06-06T09:24:09.090 回答