Annahme Return false wird bei der Authentifizierung entweder auf HTTP-Aufruf zurückgegeben werden, aber jetzt bin ich von CanLoadChildren() Methode Inorder zurück canLoad testen Aber trotz Aufruf von canLoad und Rückgabe falscher canLoad lädt immer noch Modul und Weiterleitung zu diesem Modul.kann eine Hilfe sein?Auth Guard ist auf Lazy Loaded Module in angular2 angewendet, aber es ist immer noch Umleitung trotz Ablehnung CanLoad funktioniert nicht
DankAuthService
import {
Injectable
} from '@angular/core';
@Injectable()
export class AuthService {
constructor() {}
public CanLoadChildren(): boolean {
return false;
}
}
Auth Wache Datei
import {
AuthService
} from './auth.service';
import {
Injectable
} from '@angular/core';
import {
CanActivate,
CanLoad,
Route,
ActivatedRouteSnapshot,
RouterStateSnapshot,
Router
} from '@angular/router';
@Injectable()
export class CanActivateViaAuthGuardService implements CanActivate, CanLoad {
constructor(private _authService: AuthService, private router: Router) {}
canLoad(route: Route): boolean {
console.log("Can Load Childrens Called");
console.log(route);
this.router.navigate(['/Domains']);
return this._authService.CanLoadChildren();
}
}
app.router.ts
export const APPROUTES: Routes = [
{
path: 'User',
canLoad: [CanActivateViaAuthGuardService],
loadChildren: 'app/LazyAdminConsoleModule'
}
]