ngAalin中Acl 实现 字符串型权限点

介绍:https://ng-alain.com/acl/control/zh

 

1. 在src/app/delon.module.ts 文件中 增加或修改 fnDelonACLConfig() 函数

export function fnDelonACLConfig(): DelonACLConfig {
return {
...new DelonACLConfig(),
...{
preCan: (roleOrAbility: ACLCanType) => {
const str = roleOrAbility+"";
return str.startsWith('ability.') ? { ability: [str] } : null;
}
} as DelonACLConfig
};
}

2 在const GLOBAL_CONFIG_PROVIDES中追加

{ provide: DelonACLConfig, useFactory: fnDelonACLConfig },

 

3。在页面使用如:<button acl="ability.user.edit">edit</button>

4. startup.service.ts 中测试加一入条 this.aclService.data.abilities.push("ability.user.edit");

完成

 

posted @ 2020-02-05 15:08  叶动风随  阅读(763)  评论(0)    收藏  举报