更新时间:2023-02-26 08:41:10
我在文档Wiki中找不到任何内容.但是根据消息来源和评论,似乎有一种Authorization
服务可供您利用.
I did not find something in the documentation wiki. But according to the source and comment there seems to be an Authorization
Service available which u can take advantage of.
//inject PermissionMap and Authorization
App.controller('Controller',function(PermissionMap,Authorization,$scope) {
//get the state by name an assign it to `state`
var permissionMap = new PermissionMap(state.data.permissions);
var authorizationResult = Authorization.authorize(permissionMap);
authorizationResult
.then(function () {
//authorized
})
.catch(function (rejectedPermission) {
//unauthorized
});
});
查看此代码,看看它是否有效
Check out this code and see if it works
更新
在您回复之后,我对代码进行了更深入的研究. 也许我们需要StatePermissionMap和StateAuthorization.
After ur reply, i looked deeper into the code. Maybe we need StatePermissionMap and StateAuthorization instead.
var statePermissionMap = new StatePermissionMap(state);
StateAuthorization
.authorize(statePermissionMap)
.then(function () {
//authorized
})
.catch(function (rejectedPermission) {
//unauthorized
})