作者:yangxin | 来源:互联网 | 2023-05-18 15:20
hiimgoingtomanagetheuseraccesslevelswithangularjsandjson.ihavetwoarraysoneforme
hi i'm going to manage the user access levels with angular js and json. i have two arrays one for menu structure and the other for access levels.
嗨,我将用角度js和json管理用户访问级别。我有两个阵列,一个用于菜单结构,另一个用于访问级别。
current access levels :
当前访问级别:
$scope.current_access_levels ={
"can_home":{"title":"home","value":true},
"can_mail":{"title":"mail","value":false}
};
menu structure :
菜单结构:
$scope.menu = [
{"id":"1","name":"home","aclvl":"can_home"},
{"id":"2","name":"mail","aclvl":"can_mail"}
];
every menu field has an "aclvl" that matches with the names of objects in "current_access_level" array.
每个菜单字段都有一个“aclvl”,它与“current_access_level”数组中的对象名称相匹配。
what i'm going to do is something like this :
我要做的是这样的事情:
for example if the "aclvl" of "men" is equal to "can_home" the checkbox value should be equal to "aclvl.can_home.value". any body knows how should i handle this!? i have added a fiddle to clear what i'm supposing to do. thanks
例如,如果“men”的“aclvl”等于“can_home”,则复选框值应等于“aclvl.can_home.value”。任何人都知道我该怎么处理这个!?我添加了一个小提琴来清除我想要做的事情。谢谢
angular.module('app',[])
.controller('appCtrl',function($scope){
$scope.current_access_levels ={"can_home":{"title":"home","value":true},"can_mail":{"title":"mail","value":false}};
$scope.menu = [{"id":"1","name":"home","aclvl":"can_home"},{"id":"2","name":"mail","aclvl":"can_mail"}];
});
current access levels
{{aclvl.title}}
{{current_access_levels}}
menu structure
1 个解决方案