我正在尝试使用相同的选项标记和值生成多个选择标记。它是一个用户表,将显示用户名,然后显示为他们选择的组,但我无法为每个用户选择正确的用户名而不是全部更改。
sh
var app = angular.module('todo',[]);
app.controller('option_list',function($scope){
$scope.users = [
{"id":0, "group_id":0, "name":"Caleb"},
{"id":1, "group_id":2, "name":"Christie"},
{"id":2, "group_id":0, "name":"Dawson"},
{"id":3, "group_id":0, "name":"Kalen"}
]
$scope.groups = [
{"id":0, "name":"First Group"},
{"id":1, "name":"Second Group"},
{"id":2, "name":"Third Group"},
{"id":3, "name":"Fourth Group"}
]
for(var i = 0; i < $scope.users.length; i++){
$scope.selected = {
group: $scope.groups[$scope.users[i].group_id]
}
}
})