"/:hl/p12": {
get controller(): {
return page1Controller || page2Controller; //тут могут быть любые условия
},
handlerMethod: "onInit",
onLeaveHandlerMethod: "onLeave"
},
let pageController;
if(true) {
pageController = require("../modules/page1Controller"). page1Controller;
} else {
pageController = require("../modules/page2Controller"). page2Controller;
}
"/:hl/p12": {
controller: pageController,
handlerMethod: "onInit",
onLeaveHandlerMethod: "onLeave"
},
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private userService: UserService) {}
canActivate(route: ActivatedRouteSnapshot, state:RouterStateSnapshot): Promise<boolean>|boolean {
return this.userService.isAuth;
}
}
{
path: 'logout',
component: LogoutComponent,
canActivate: [AuthGuard]
},
{
path: 'login',
component: LoginComponent,
canActivate: [GuestGuard]
},
npm install --save jquery
npm install --save @types/jquery
const req = this.request(url);
req.on('response', (res) => {
req.pipe(this.feedParser);
});
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private userService: UserService) {}
canActivate(route: ActivatedRouteSnapshot, state:RouterStateSnapshot): Promise<boolean>|boolean {
return this.userService.isAuth;
}
}
{
path: 'logout',
component: LogoutComponent,
canActivate: [AuthGuard]
},
{
path: 'login',
component: LoginComponent,
canActivate: [GuestGuard]
},