Update Angular template so that FetchDataComponent emulates what AngularCLI generates #205

Closed
opened 2025-08-09 17:15:24 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @PurdueGuy531 on 1/28/2018

Can you please update the Angular template so that by default the FetchDataComponent emulates what the AngularCLI generates when you add a new component via ng g c MyComponent?

More specifically:

  1. IMPORTANT: Implement OnInit and make your service call within the ngOnInit() method.

  2. Consider injecting in a service class and wrapping your weatherforecast logic in that service. This demonstrates dependency injection and is more unit test friendly.

2B) If that's to much - maybe just a code comment that states that this is a simple example with 'http.get' and that the more recommended approach is to pass in a service class to trigger in ngOnInit, ideally using observables (via .subscribe).

Great work guys! keep it up!

-Chris

*Originally created by @PurdueGuy531 on 1/28/2018* Can you please update the Angular template so that by default the FetchDataComponent emulates what the AngularCLI generates when you add a new component via ng g c MyComponent? More specifically: 1) IMPORTANT: Implement OnInit and make your service call within the ngOnInit() method. 2) Consider injecting in a service class and wrapping your weatherforecast logic in that service. This demonstrates dependency injection and is more unit test friendly. 2B) If that's to much - maybe just a code comment that states that this is a simple example with 'http.get' and that the more recommended approach is to pass in a service class to trigger in ngOnInit, ideally using observables (via .subscribe). Great work guys! keep it up! -Chris
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#205
No description provided.