【发布时间】:2014-11-04 04:42:45
【问题描述】:
检查json中的值是否可用。我正在使用以下代码
$scope.bindRoles.push
Name: "Name"
Editable: if item in $scope.rolesOfLoggedUser then true else false // here i am checking if item is present in $scope.rolesOfLoggedUser then set value of Editable as true.
其中,$scope.rolesOfLoggedUser = ["Admin", "Role1", "Role2"]
我的要求是,我想在 if 语句中再检查一件事。 $scope.rolesOfLoggedUser 中存在 item 或“Admin”,然后将 Editable 的值设置为 true。
我该怎么做?
请帮忙, 谢谢
【问题讨论】:
-
把最后多余的语句去掉即可:
Editable: item in $scope.rolesOfLoggedUser
标签: json coffeescript