关键我有变量:显示值,当你知道在AngularJS
$scope.rolesData = [{id : '1', name : 'user'}, {id : '2', name : 'superuser'},{id : '3', name : 'admin'}];
而且我从数据库得到了与整数值,它告诉我什么是角色的用户对象。这是从1到3 user.userRole为1,2或3
$scope.users = adminUserSvc.query(); //From DB
一切都在选择干活罚款:
<tr ng-repeat="user in users">
...
<select class="form-control" ng-model="user.userRole" ng-options="role.id as role.name for role in rolesData">
</select>
但我不知道我该怎么让里面的一样{ {}}?如果我知道user.userRole给我的ID为1,那么我会得到名称的价值?
这是ngRepeat内:
<div ng-hide="editingUsers[user.userId]">{{rolesDataSOMETHING??}}</div>
对不起,我没有告诉你,这user.userRole从DB到来,有只有int从1到3. – Sami
对不起,你能解释一下吗?你是否在数据库的''scope''上设置''user.userRole''? –
不,我有一个我从DB获得的范围内的用户列表。然后我使用ng-repeat来显示列表中的每个用户。每个用户都可以修改。 – Sami