December 2017
Beginner
372 pages
10h 32m
English
So, now we have routes defined and they have been stitched together using routerLink with the menu options. When we click on any of these menu options, Angular changes the URL of the browser and loads the respective component, which would be NewsComponent in our case.
The last step is to be able to access the menu option selected, and make the web service call with that selected news outlet so as to fetch the news articles. The following is the code we have in our ngOnInit in the NewsComponent.ts file:
ngOnInit() { this.route.data.subscribe(data => { this.feedType = (data as any).feedType; this.source = (data as any).source;});this._service.fetchNewsFeed(this.feedType) .subscribe( items => this.latest_news ...
Read now
Unlock full access