Closed WO8TimeSpace175ZERO2 closed 5 years ago
静的ページ表示の際に、 export class ArticleComponent implements OnInit { id = ''; articleContent: Promise;
constructor(private route: ActivatedRoute, private articleService: ArticleService) { }
ngOnInit() { this.route.params.subscribe( params => { this.id = params.id; this.articleContent = this.articleService.retrieveArticleContent(params.id); } ); } という風にActivatedRoute.params.subscribeメソッドの引数に渡すサブスクライバの終端関数で URIパラメータを取っていたが、 次の記事を読むと、このような方法をする必要がない。 https://ionicframework.com/blog/navigating-the-change-with-ionic-4-and-angular-router/
ActivatedRoute.snapshot.paramMap.getメソッドを使う事でURIパラメータの取得が可能なため、 それで書き直しをする。
次のコミットで対応 https://github.com/WO8TimeSpace175ZERO2/genma-taisen-to-the-north-of-kanamachi/commit/752dc6793e97dc067bdd6c68763ea4f102b8d08a
静的ページ表示の際に、 export class ArticleComponent implements OnInit { id = ''; articleContent: Promise;
constructor(private route: ActivatedRoute, private articleService: ArticleService) { }
ngOnInit() { this.route.params.subscribe( params => { this.id = params.id; this.articleContent = this.articleService.retrieveArticleContent(params.id); } ); } という風にActivatedRoute.params.subscribeメソッドの引数に渡すサブスクライバの終端関数で URIパラメータを取っていたが、 次の記事を読むと、このような方法をする必要がない。 https://ionicframework.com/blog/navigating-the-change-with-ionic-4-and-angular-router/
ActivatedRoute.snapshot.paramMap.getメソッドを使う事でURIパラメータの取得が可能なため、 それで書き直しをする。