angular send data to parent component

Solutions on MaxInterview for angular send data to parent component by the best coders in the world

showing results for - "angular send data to parent component"
Marie
11 Jan 2021
1import { Component, Output, EventEmitter } from '@angular/core';
2
3@Component({
4  selector: 'app-child',
5  template: `
6      <button (click)="sendMessage()">Send Message</button>
7  `,
8  styleUrls: ['./child.component.css']
9})
10export class ChildComponent {
11
12  message: string = "Hola Mundo!"
13
14  @Output() messageEvent = new EventEmitter<string>();
15
16  constructor() { }
17
18  sendMessage() {
19    this.messageEvent.emit(this.message)
20  }
21}
22