Linked Questions
75 questions linked to/from What is the proper use of an EventEmitter?
1
vote
0
answers
178
views
Property observed not exist on type EventEmitter [duplicate]
We use angular (11.2.14) and we updated rxjs library to 7.1.0.
From that point we have this error "Property 'observers' does not exist on type 'EventEmitter'" in multiple places.
According ...
282
votes
7
answers
196k
views
Delegation: EventEmitter or Observable in Angular
I am trying to implement something like a delegation pattern in Angular.
When the user clicks on a nav-item, I would like to call a function which then emits an event which should in turn be handled ...
132
votes
3
answers
229k
views
How to subscribe to an event on a service in Angular2?
I know how to raise an event with the EventEmitter. I can also attach a method to be called if I have a component like this:
<component-with-event (myevent)="mymethod($event)" />
When I have a ...
61
votes
4
answers
173k
views
How to import component into another root component in Angular 2
I am trying to import component from one file another root component file.
it give error as ..
zone.js:484 Unhandled Promise rejection: Template parse errors:
'courses' is not a known element:
1....
24
votes
5
answers
47k
views
How to use two way data binding between components in angular 2?
First I've created a User class:
export class User {
name: string;
email: string;
}
Then I've got my CoreComponent which uses the FormInputComponent as well as creating a public user from the ...
34
votes
3
answers
33k
views
How to unsubscribe from EventEmitter in Angular 2?
export declare class EventEmitter<T> extends Subject<T> {
/**
* Creates an instance of [EventEmitter], which depending on [isAsync],
* delivers events synchronously or ...
71
votes
2
answers
36k
views
When to use Observable vs EventEmitter vs Dot Rule for change detection in angular2
There are three methods I have seen to manage change detection in Angular2.
Observables
@Injectable()
export class TodosService {
todos$: Observable<Array<Todo>>;
private ...
27
votes
2
answers
51k
views
Angular 2 component directive not working
I am a beginner in angular 2 and I want to make my first app working. I am using TypeScript.
I have the app.component.ts in which I have made a directive to another compoent called todos.component but ...
29
votes
2
answers
32k
views
angular 2: using a service to broadcast an event
I'm trying to get a button click in one component to put focus on an element on another component. (Frankly, I don't understand why this must be so complex, but I have not been able to implement any ...
21
votes
2
answers
31k
views
Angular2 version RC.6 "directives" inside @Component Error
I am using Angular2 and have downloaded package.json from the official website. When I am trying to use "directives" inside @Component decorator I am getting this error.
I have attached my code ...
14
votes
5
answers
24k
views
Dynamically change header string in angular 2
In my app Im trying to dynamically change the title in my header component depending on the page that Im on, so In my header component I want to use a
<h1>{{title}}</h1>
and I want it to ...
22
votes
1
answer
12k
views
How can I use an event emitter on a dynamically added component?
Working off of Eric Martinez' answer from Angular 2 - Adding / Removing components on the fly, I want to limit the amount of components created. And then after deleting a component, I'm trying to emit ...
18
votes
1
answer
11k
views
Unable to figure out correct EventEmitter or Observable Syntax in Angular2 Services
I'm having a hard time finding much in the way of examples/guides for using observables in an Angular2 service. There is stuff for html templates binding with EventEmitter but that doesn't seem right ...
8
votes
2
answers
49k
views
Angular 4 emitting and subscribing to an event in a shared service
I am emitting an event in my main component:
main.component.ts
this.sharedService.cartData.emit(this.data);
Here is my sharedService.ts
import { Component, Injectable, EventEmitter } from '@angular/...
14
votes
1
answer
6k
views
RxJS fromEvent operator with output EventEmitter in Angular
Say there's ChildComponent which emits out an event called someEvent. Obviously, I can catch the event in ParentComponent declaring like, <child-component (someEvent)="onSomeEvent($event)"></...