CanActivate时如何从Guard返回Observable.create(true)

时间:2017-01-04 21:50:24

标签: angular angular2-routing

我有以下代码......

UNION ALL

它有效但现在我需要调用另一个服务来复制我改为

@Injectable()
export class CanActivateIfWork implements CanActivate {
    constructor( public myService: MyService ) { }
    canActivate(
        route: ActivatedRouteSnapshot,
        state: RouterStateSnapshot,
    ) {
       return this.myService.shortPromise().map(message => {
          return true;
       });
    }
}

然而,这似乎不起作用。我也试过了......

@Injectable()
export class CanActivateIfWork implements CanActivate {
    constructor( public myService: MyService ) { }
    canActivate(
        route: ActivatedRouteSnapshot,
        state: RouterStateSnapshot,
    ) {
       return this.myService.shortPromise().map(message => {
          return Observable.create(true);
       });
    }
}

如何将此作为可观察对象返回?

0 个答案:

没有答案