RROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'home'
Error: Cannot match any routes. URL Segment: 'home'
at ApplyRedirects.noMatchError (webpack-internal:///./node_modules/@angular/router/esm5/router.js:1848)
at CatchSubscriber.eval [as selector] (webpack-internal:///./node_modules/@angular/router/esm5/router.js:1813)
at CatchSubscriber.error (webpack-internal:///./node_modules/rxjs/_esm5/operators/catchError.js:108)
at MapSubscriber.Subscriber._error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:136)
at MapSubscriber.Subscriber.error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:110)
at MapSubscriber.Subscriber._error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:136)
at MapSubscriber.Subscriber.error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:110)
at MapSubscriber.Subscriber._error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:136)
at MapSubscriber.Subscriber.error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:110)
at LastSubscriber.Subscriber._error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:136)
at ApplyRedirects.noMatchError (webpack-internal:///./node_modules/@angular/router/esm5/router.js:1848)
at CatchSubscriber.eval [as selector] (webpack-internal:///./node_modules/@angular/router/esm5/router.js:1813)
at CatchSubscriber.error (webpack-internal:///./node_modules/rxjs/_esm5/operators/catchError.js:108)
at MapSubscriber.Subscriber._error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:136)
at MapSubscriber.Subscriber.error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:110)
at MapSubscriber.Subscriber._error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:136)
at MapSubscriber.Subscriber.error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:110)
at MapSubscriber.Subscriber._error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:136)
at MapSubscriber.Subscriber.error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:110)
at LastSubscriber.Subscriber._error (webpack-internal:///./node_modules/rxjs/_esm5/Subscriber.js:136)
at resolvePromise (webpack-internal:///./node_modules/zone.js/dist/zone.js:809)
at resolvePromise (webpack-internal:///./node_modules/zone.js/dist/zone.js:775)
at eval (webpack-internal:///./node_modules/zone.js/dist/zone.js:858)
at ZoneDelegate.invokeTask (webpack-internal:///./node_modules/zone.js/dist/zone.js:421)
at Object.onInvokeTask (webpack-internal:///./node_modules/@angular/core/esm5/core.js:4956)
at ZoneDelegate.invokeTask (webpack-internal:///./node_modules/zone.js/dist/zone.js:420)
at Zone.runTask (webpack-internal:///./node_modules/zone.js/dist/zone.js:188)
at drainMicroTaskQueue (webpack-internal:///./node_modules/zone.js/dist/zone.js:595)
at ZoneTask.invokeTask [as invoke] (webpack-internal:///./node_modules/zone.js/dist/zone.js:500)
at invokeTask (webpack-internal:///./node_modules/zone.js/dist/zone.js:1517)
defaultErrorLogger @ webpack-internal:///./node_modules/@angular/core/esm5/core.js:1664
//
resolve(route:ActivatedRouteSnapshot,state:RouterStateSnapshot):Observable<Product>|Promise<Product>|Product{
let productId:number = route.params["id"];
if(productId == 1){
return new Product(1,"inphone7");
}else{
console.log(productId);
//this.router.navigate(['home']);
this.router.navigate(['/home']);
return undefined;
}
}
}
//
把你的路由定义放出来