i define my component in one file and i want to send data form parent to child component in parent function is work properly but eventEmitter not emit
this is my component file have two component
import { Component, OnInit, Inject ,EventEmitter,Output} from '@angular/core';
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
export interface DialogData {
name: string;
}
@Component({
selector: 'app-new-time-register',
templateUrl: './new-time-register.component.html',
styleUrls: ['./new-time-register.component.scss']
})
export class NewTimeRegisterComponent implements OnInit {
constructor(public dialog: MatDialog) { }
ngOnInit() {
}
openDialog(modal:string): void {
const dialogRef = this.dialog.open(RegisterDialog, {
width: '480px',
data: {name: modal}
});
}
testEvent(value){
console.log(value,"OOOOOOOOOOOOOOOOOOOO");
}
}
@Component({
selector: 'register-dialog',
templateUrl: 'register-dialog.html',
styleUrls: ['./new-time-register.component.scss']
})
export class RegisterDialog{
constructor(
public dialogRef: MatDialogRef<RegisterDialog>,
@Inject(MAT_DIALOG_DATA) public data: DialogData) {}
showAllPersons: Boolean = false;
onNoClick(): void {
this.dialogRef.close();
}
@Output() testEmit = new EventEmitter<string>();
testEventEmitter(){
console.log('TTTTTTTTTTTTTTTTTT');
this.testEmit.emit("Test EventEmitter");
}
}
this is register-dialog.html file
<span class="panel-title" (click)='testEventEmitter()'>Computicate Trial Account Manager</span>
here is my child app-new-time-register html file
<register-dialog (testEmit)='testEvent($event)'></register-dialog>
here is a child component
testEvent(value){
console.log(value,"OOOOOOOOOOOOOOOOOOOO");
}
send data form parent to child component
not sure you get it right,@output
is for child->parent . – super cool