介绍: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");
完成
原文:https://www.cnblogs.com/tiandidao/p/12263902.html