Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

send event to child component angular

Parent-Component

eventsSubject: Subject<void> = new Subject<void>();

emitEventToChild() {
  this.eventsSubject.next();
}


Parent-HTML

<child [events]="eventsSubject.asObservable()"> </child>


Child-Component

private eventsSubscription: Subscription;

@Input() events: Observable<void>;

ngOnInit(){
  this.eventsSubscription = this.events.subscribe(() => doSomething());
}

ngOnDestroy() {
  this.eventsSubscription.unsubscribe();
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to check consecutive characters in javascript 
Javascript :: Check ratelimit discord js 
Javascript :: angular datatable reload with pagination 
Javascript :: addclass jquery 
Javascript :: vuejs input text 
Javascript :: javascript onmouseover change image 
Javascript :: change html using jquery 
Javascript :: sequelize delete item 
Javascript :: get datetime yesterday angular 
Javascript :: javascript flatten an array 
Javascript :: date-and-time npm 
Javascript :: keypress event 
Javascript :: see all functions in a website with console 
Javascript :: react 404 page not found 
Javascript :: react dictionary key value avec 2 variable 
Javascript :: replace all occurrences of a string in javascript 
Javascript :: sort divs alphabetically jquery 
Javascript :: fetch in for loop javascript 
Javascript :: javascript object to base64 
Javascript :: javascript check less width of window 
Javascript :: usestate hook with prevstate 
Javascript :: javascript infinite parameters 
Javascript :: check scroll top height in react js 
Javascript :: jquery siblings 
Javascript :: javascript function required arguments 
Javascript :: btn.addeventlistener 
Javascript :: gulp runSequence 
Javascript :: js read from json1 
Javascript :: multiple line string javascript 
Javascript :: how to make a deep copy in javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =