私は/my/route/8000
4角:空のルートのparam利回りエラーのルートをアクティブ化します。ヌル「あなたが提供する 『』ストリームが期待されていた...」
に行けばそれは動作します。
しかし、私はノールートのparamsで/my/route
に移動しようとすると、私はエラーを取得する:
You provided 'null' where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
ngOnInit() {
// the observable method
this.route.paramMap
.switchMap((params: ParamMap) => {
this.number = params.get('number');
return params.get('number');
})
.subscribe((number) => { return; });
}
ルート
export const routes: Routes = [{
path : 'my',
children: [{
path : '',
pathMatch : 'full',
redirectTo: 'route'
}, {
path : 'route',
component: SubscriberRegisterComponent,
}, {
path : 'route/:number', // gets the route parameters
component: SubscriberRegisterComponent,
}]
}];
私は私を訪問することはできませんどのように来ますルートパラメータなしで直接ルートを作成しますか?私は上記の観察可能な方法をコメントアウトしてから、私は空のparams
this.number = this.route.snapshot.paramMap.get('number ');
ありがとう、それはそれを解決しました。作業のために '.do()'と '.subscribe()'を使うことを覚えています。 – TetraDev