我有一个带有检查权限的 Authorize 属性的 api 方法
[Authorize(ReadIndexes)]
public async Task<IActionResult> GetIndexes ()
{
...
}
是否有等效的方法来装饰一个方法来检查 Angular 中的权限,以便在权限不存在时不执行 api 调用
##????##
getIndexes(): Observable<Index[]> {
// dont want to check in the method like below
if(checkPerms("ReadIndexes")===true){
...
}
}
最佳答案
有装饰器但是你必须为装饰器写逻辑
使用装饰器的例子是组件
@Component({
selector: "thingy",
template: `foo`
})
class MyComponent {
}
This是一篇关于如何编写自定义装饰器的博文
关于javascript - Angular7 等同于 C# 属性装饰器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56683335/