angualar subscribe parent event

      
        content_copy
      
      import { Component } from '@angular/core';

import { MissionService } from './mission.service';

@Component({
  selector: 'app-mission-control',
  template: `
    <h2>Mission Control</h2>
    <button (click)="announce()">Announce mission</button>
    <app-astronaut *ngFor="let astronaut of astronauts"
      [astronaut]="astronaut">
    </app-astronaut>
    <h3>History</h3>
    <ul>
      <li *ngFor="let event of history">{{event}}</li>
    </ul>
  `,
  providers: [MissionService]
})
export class MissionControlComponent {
  astronauts = ['Lovell', 'Swigert', 'Haise'];
  history: string[] = [];
  missions = ['Fly to the moon!',
              'Fly to mars!',
              'Fly to Vegas!'];
  nextMission = 0;

  constructor(private missionService: MissionService) {
    missionService.missionConfirmed$.subscribe(
      astronaut => {
        this.history.push(`${astronaut} confirmed the mission`);
      });
  }

  announce() {
    const mission = this.missions[this.nextMission++];
    this.missionService.announceMission(mission);
    this.history.push(`Mission "${mission}" announced`);
    if (this.nextMission >= this.missions.length) { this.nextMission = 0; }
  }
}
    

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
parent and child event in angular code evolution angular child subscribe to parent event parernt to child event angular emit events from parent to child angular 10 angular child listen to parent changes angular child listen to parent event pass event from parent to child angular hoe to listen events from child in parent component in angular emit parent to child angular passing event to child angular child component listen to parent event emit events to child emit event to child component send event parent to child angular emmiting child event angular send event from parent to child fire event from parent to child in angular angular eventemitter from child listen on parent angular listen on event from parent to child emit from parent to child angular angular eventemitter from parent to child angular emitting event from parent to child parent event to child angular emit event to child component angular2 angular ngchanges listen to parent angular event emitter from parent to child angular pass event to child pass event emitter from parent to child angular eventemitter parent to child parent to child event emitter parent to child event! angular send event from parent to child send event from parent to child angular child listen for parent property change angular 2 pass event to child component angular emit value from parent to child angular Child listens for parent event in Angular 10 with services listen to parent event in child angular 10 send event from parent to child service angualr emit event from parent to child Angular send event to child coponent angular emit event to child parent to child event angular listen change from parent to child event angular how to emit event from parent to child component angular 6 angualar subscribe parent event angular parent emit event to child Receive an event from parent angular Receive a event from parent angular angular subscripbe parent events
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source