December 2017
Beginner
372 pages
10h 32m
English
In the previous section, we added the dependency of the NewsapiService to our NewsComponent class. Now it's time to use that dependency to call the fetchNewsFeed method and subscribe to the observable response. As we want to make sure that the new articles are loaded when we load the page, we would need to make the call to our web service in the ngOnInit method of the NewsComponent class.
The ngOnInit method is one of the life cycle hooks that are provided by Angular to help us intercept the page load cycle. The subscribe method from the rxJs observable library has two overloaded implementations:
this._service(successFunc, errorFunc);this._service(successFunc, errorFunc, completeFunc);
The successFunc is called ...
Read now
Unlock full access