最近、私はデータは、これが
"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();
}
}
を助け..hope解決することができました