我在HTML中初始化一个转发器colorSetOne,然后,我想用另一个转发器colorSetTwo替换,如何做到这一点(它可以由一个事件触发)?这里是jsfiddle:http://jsfiddle.net/8xWRm/
HTML:
<ul ng-app ng-controller="cubeCtrl">
<li ng-repeat="color in colorSetOne">{{color}}</li>
javascipt的:
function cubeCtrl($scope){
$scope.colorSetOne = ["red","blue","green","oringe"]
$scope.colorSetTwo = ["blue","red","black","white"]
}
答案 0 :(得分:1)
您只需要重新分配colorSetOne
$scope.colorSetOne = $scope.colorSetTwo;
如果您想保留colorSetOne
,那么您应该将转发器放在另一个变量colorSet
上,并根据需要分配相应的颜色集。