Angularjs 控制器中基于模型的角度更新ng重复

Angularjs 控制器中基于模型的角度更新ng重复,angularjs,angularjs-ng-repeat,Angularjs,Angularjs Ng Repeat,我是个新手。我正在尝试使用ng repeat显示品牌列表。它工作得很好。但当我点击下一步按钮时,它也应该改变accorading数组索引。这对我不起作用。请帮我解决这个问题。并告诉最好的方法来构造这种类型的案例。我的代码在下面 var数据=[{“度量”:“度量1”,“风味”:[{“FlavorName”:“FlavorName1”,“TotalBrands”:[{“BrandName”:“Brand1”},{“BrandName”:“Brand2”},{“FlavorName”:“FlavorN

我是个新手。我正在尝试使用ng repeat显示品牌列表。它工作得很好。但当我点击下一步按钮时,它也应该改变accorading数组索引。这对我不起作用。请帮我解决这个问题。并告诉最好的方法来构造这种类型的案例。我的代码在下面

var数据=[{“度量”:“度量1”,“风味”:[{“FlavorName”:“FlavorName1”,“TotalBrands”:[{“BrandName”:“Brand1”},{“BrandName”:“Brand2”},{“FlavorName”:“FlavorName2”,“TotalBrands”:[{“BrandName”:“Brand3”},{“BrandName”:“Brand4”}]}]; var myApp=angular.module(“测量”,[])


以前的
风味计数{{flavourCount}

度量值:{{surveyList[measureCount].Measure}

风味名称:{{Flavours[flavourCount].FlavourName}

所有品牌

{{brand.BrandName}

下一个 myApp.controller(“数据控制器”、[“$scope”、函数($scope){ $scope.name=“sajid”; $scope.measureCount=0; $scope.flavourCount=0; $scope.surveyList=数据; $scope.listLength=$scope.surveyList.length; $scope.flavors=$scope.surveyList[$scope.measureCount].flavors; $scope.totalBrands=$scope.flavours[$scope.flavourCount].totalBrands; $scope.getPreviousMeasure=函数(){ 如果($scope.measureCount==0){ $scope.measureCount=0; }否则{ $scope.measureCount=$scope.measureCount-1; } }; $scope.getNextMeasure=function(){ 如果($scope.listLength-1==$scope.measureCount){ $scope.measureCount=0; }否则{ $scope.measureCount=$scope.measureCount+1; } }; $scope.getPreviousFlavor=函数(){ 如果($scope.flavors==0){ $scope.measureCount=$scope.measureCount-1; $scope.flavourCount=0; }否则{ $scope.flavourCount=$scope.flavourCount-1; } }; $scope.getNextFlavour=function(){ 如果($scope.flavours.length==$scope.flavourCount){ $scope.measureCount=$scope.measureCount+1; $scope.flavourCount=0; }否则{ $scope.flavourCount=$scope.flavourCount+1; } };

}]))

应该插入的GetPreviousFlavor和GetNextFlavor中的最后一行

$scope.totalBrands = $scope.flavours[$scope.flavourCount].TotalBrands;
这使totalBrands焕然一新

$scope.getPreviousFlavour = function(){

    if($scope.flavours === 0){
        $scope.measureCount = $scope.measureCount - 1;
        $scope.flavourCount = 0;
    }else{
        $scope.flavourCount = $scope.flavourCount -1;   
    }
    $scope.totalBrands = $scope.flavours[$scope.flavourCount].TotalBrands;
};

$scope.getNextFlavour = function(){
    if($scope.flavours.length  === $scope.flavourCount){
        $scope.measureCount = $scope.measureCount + 1;
        $scope.flavourCount = 0;
    }else{
        $scope.flavourCount = $scope.flavourCount + 1;  
    }
    $scope.totalBrands = $scope.flavours[$scope.flavourCount].TotalBrands;  
};

很抱歉,无法将示例数据添加到代码部分。我无法获取您的信息。你能用不同的方式解释吗。或者在代码中显示
$scope.getPreviousFlavour = function(){

    if($scope.flavours === 0){
        $scope.measureCount = $scope.measureCount - 1;
        $scope.flavourCount = 0;
    }else{
        $scope.flavourCount = $scope.flavourCount -1;   
    }
    $scope.totalBrands = $scope.flavours[$scope.flavourCount].TotalBrands;
};

$scope.getNextFlavour = function(){
    if($scope.flavours.length  === $scope.flavourCount){
        $scope.measureCount = $scope.measureCount + 1;
        $scope.flavourCount = 0;
    }else{
        $scope.flavourCount = $scope.flavourCount + 1;  
    }
    $scope.totalBrands = $scope.flavours[$scope.flavourCount].TotalBrands;  
};