Angular2: How to load data before rendering the component?

update If you use the router you can use lifecycle hooks or resolvers to delay navigation until the data arrived. https://angular.io/guide/router#milestone-5-route-guards To load data before the initial rendering of the root component APP_INITIALIZER can be used How to pass parameters rendered from backend to angular2 bootstrap method original When console.log(this.ev) is executed after this.fetchEvent();, this … Read more

What is the proper use of an EventEmitter?

TL;DR: No, don’t subscribe manually to them, don’t use them in services. Use them as is shown in the documentation only to emit events in components. Don’t defeat angular’s abstraction. Answer: No, you should not subscribe manually to it. EventEmitter is an angular2 abstraction and its only purpose is to emit events in components. Quoting … Read more

What is the correct way to share the result of an Angular Http network call in RxJs 5?

EDIT: as of 2021, the proper way is to use the shareReplay operator natively proposed by RxJs. See more details in below answers. Cache the data and if available cached, return this otherwise make the HTTP request. import {Injectable} from ‘@angular/core’; import {Http, Headers} from ‘@angular/http’; import {Observable} from ‘rxjs/Observable’; import ‘rxjs/add/observable/of’; //proper way to … Read more

techhipbettruvabetnorabahisbahis forumuedusedusedusedueduedusedueduedusedus