Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

child to perent data transfer in angular

//app.component.ts:
 prenettochild(name: any) {
    alert(name);
  }
//app.html:
<app-child (perentfunction)="prenettochild($event)"></app-child>
//child.component.ts:
  @Output() perentfunction: EventEmitter<any> = new EventEmitter();
//button onclick function in child:
 callbuttonfunction() {
    this.perentfunction.emit('hello');
  }
//child.html:
<button (click)="callbuttonfunction()">call perent function into child</button>
 
PREVIOUS NEXT
Tagged: #child #perent #data #transfer #angular
ADD COMMENT
Topic
Name
4+7 =