All Questions

166
votes
18answers
47641 views

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

By using Http, we call a method that does a network call and returns an http observable: getCustomer() { return this.http.get('/someUrl').map(res => res.json()); } If we take this observab...
109
votes
2answers
85347 views

What is the proper use of an EventEmitter?

I've read questions like Access EventEmitter Service inside of CustomHttp where the user uses EventEmitter in his service, but he was suggested in this comment not to use it and to use instead Obser...
91
votes
9answers
76684 views

How do I create a singleton service in Angular 2?

I've read that injecting when bootstrapping should have all children share the same instance, but my main and header components (main app includes header component and router-outlet) are each getting ...
56
votes
3answers
88595 views

Angular2: How to load data before rendering the component?

I am trying to load an event from my API before the component gets rendered. Currently I am using my API service which I call from the ngOnInit function of the component. My EventRegister component...
61
votes
1answers
15791 views

How to avoid imports with very long relative paths in Angular 2?

How can I introduce something like 'my-app-name/services' to avoid lines like the following import? import {XyService} from '../../../services/validation/xy.service';
5
votes
1answers
6047 views

Angular 2 - communication of typescript functions with external js libraries

Using Javascript Infovis Toolkit as an external library for drawing graph and trees. I need to manipulate the onClick method of nodes in order to asynchronously sending an HTTP GET request to the serv...
14
votes
3answers
9449 views

How can I watch for changes to localStorage in Angular2?

I was trying to figure out how to get a menu to appear and disappear based on being logged in in a previous post. But I think a better and possibly easier question would be, how can I watch for chang...
21
votes
5answers
16540 views

How to use Dependency Injection (DI) correctly in Angular2?

I have been trying to figure out how the (DI) Dependency Injection work in Angular2. I ran into lots of problem/issue every time when I tried to Inject a service/or class into my components. From d...
20
votes
3answers
24672 views

Angular2 - Share data between components using services

I have an object that I want to share between my components into an Angular2 app. Here is the source of the first component: /* app.component.ts */ // ...imports import {ConfigService} from './conf...
2
votes
2answers
1938 views

Angular2 - Interaction between components using a service

I have two component A and B, where component A contains a button. I wish when user click on this button, fire a function on component B <A></A> <router-outlet></router-outlet>...

Previous Next