I have a child component as
export class AlertComponent implements OnInit {
@Input() messageData: string | string[];
constructor() { }
ngOnInit(): void {
}
}
I have a parent component where in template I use the above component
<app-alert *ngIf="!!alertsCount" [type]="'danger'"
[messageData]="alertMessageData"></app-alert>
<mat-select class="select--width--130" (selectionChange)="changeAlertType($event)" [(value)]="alertType" placeholder="Alert Types">
<mat-option *ngFor="let alertType of alertTypes" [value]="alertType.name">
{{ alertType.name }}
</mat-option>
</mat-select>
in parent component ts
getAlertMessageData(alertType: string) {
switch (alertType) {
case 'firing':
case 'silenced':
case 'resolved':
this.alertMessageData = `There are ${this.alertsCount} ${alertType} alerts`;
break;
case 'all':
this.alertMessageData = `There are ${this.alertsCount} alerts`;
break;
}
console.log(this.alertMessageData);
}
changeAlertType(event: MatSelectChange) {
this.alertType = event.value;
this.getAlertMessageData(event.value);}
However the message data does not get updated when I change the selection of alert type, how do I pass messageData so that it is updated after I change mat-select?