没有看到更多的控制器代码,很难确定问题可能出在哪里。这是一个简化的工作提琴。我建议您将其与现有产品进行比较。
请注意,您不需要调用,
$scope.$apply()因为该
ng-click指令将自动为我们执行此 *** 作。
HTML:
<ul> <li ng-repeat="itemL1 in mainMenuL1Arr" ng-click="selectL2menu(itemL1.name)"> {{itemL1.name}}</li></ul><ul > <li ng-repeat="itemL2 in mainMenuL2CurArr"><a href="#"> <span>{{itemL2.name}}</span> </a> </li></ul>
Javascript:
function MyCtrl($scope) { $scope.mainMenuL1Arr = [ {name: 'one'}, {name: 'two'} ]; $scope.mainMenuL2Obj = { one: [ {name: '1.1'}, {name: '1.2'} ], two: [ {name: '2.1'}, {name: '2.2'} ] }; $scope.mainMenuL2CurArr = $scope.mainMenuL2Obj['one']; $scope.selectL2menu = function (itemL1name) { console.log(itemL1name); $scope.mainMenuL2CurArr = $scope.mainMenuL2Obj[itemL1name]; };}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)