canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
return new Promise((resolve, reject) => {
this.securityService.securityActions().subscribe(
data => {debugger;
if(data = this.authorized.find(k => k=='AGREEMENTS_VIEW','AGREEMENTS_INSERT_UPDATE')){
resolve(true);
}
if(data != this.authorized){
resolve(false);
}
},
error => {
Utils.notifyErrors(error, this.notificationsService);
}
)
});
}
如果数据包含某些“授权”项,我想设置为 true。
授权是这样形成的:
authorized = [
'AGREEMENTS_VIEW',
'PROSPECTS_VIEW',
'AGREEMENTS_INSERT_UPDATE',
'PRODUCTS_INSERT_UPDATE',
'PROSPECTS_INSERT_UPDATE',
'DOCUMENTS_VIEW',
'DOCUMENTS_INSERT_UPDATE',
];
因此,例如,如果数据包含“AGREEMENTS_VIEW”,则设置为 true。
现在,如果我在 K 上设置 2 值,它就不起作用