无法在角度为2

时间:2017-01-17 09:21:38

标签: angular angular2-routing

这可能看起来像duplicate,但我无法找到解决方案(当url参数化时)。我还找到了一个相关的issue,其状态是固定的。但这不符合我的目的。

我正在使用:

"@angular/core": "^2.3.1",
"@angular/router": "^3.3.1",


{ path : 'Account/Registration/:step', component: RegistrationComponent, pathMatch: "prefix",
    children : [
        { path: "Get-Otp", component: RegistrationComponent, resolve:{ actionData : ActionResolve}},
    ]
}

即使不会调用“canActivate”或“canActivateChild”后卫,也不会调用该决心。能否请你指出正确的方向,我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

最近我能够解析数据..希望这有帮助

"dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/flex-layout": "^2.0.0-beta.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/material": "^2.0.0-beta.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "angularfire2": "^2.0.0-beta.6",
    "core-js": "^2.4.1",
    "firebase": "^3.6.4",
    "hammerjs": "^2.0.8",
    "rxjs": "^5.0.2",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },

const appRoutes: Routes = [
    {
        path: '',
        pathMatch: 'full',
        component: HomeComponent,
        resolve: {
            auth: AuthResolverService
        }
    }
];



import { Injectable } from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ActivatedRouteSnapshot, RouterStateSnapshot, Resolve, Router} from '@angular/router';

@Injectable()
export class AuthResolverService implements Resolve<any> {

  constructor(private af: AngularFire, private router: Router) {
    console.log('constructor: AuthResolverService');
    this.af.auth.subscribe(
      user => {
        console.log('constructor: AuthResolverService --> ', user);
      },
      error => console.trace(error)
    );
  }

  resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> {
    console.log('AuthResolverService');
    return this.af.auth.first();
  }

}