Angular: How I can pass a value to child component after successful output eventemitter

327 views Asked by At

How I can setvalue to true in angular after successful emit operation. How I can pass a flag to app.child.ts after successful api call in parent component?

app.parent.html

<form [formGroup]="productForm">
  <input matInput
         formControlName="amount"
         type="number"/>
  <button *ngIf="hasValue"
         (click)="onItemRemoved(element, index)">
         Remove
  </button>
</from>

app.parent.ts

@Output() remove: EventEmitter<any> = new EventEmitter();
    
onItemRemoved(value, index) {
   this.remove.emit({ value, index });
}

app.child.html

<app-parent (remove)="remove($event)" </app-parent>

app.child.ts

remove(event) {
  console.log('item removing with api call...');
}
0

There are 0 answers