0

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...');
}
SKL
  • 1,243
  • 4
  • 32
  • 53
  • 2
    the child component hold the parent component selector?? something is not clear in the scenario.. – Eli Porush Mar 16 '22 at 10:41
  • Can you explain more the scenario? so after emitting an event from the child to parent, you want a return from parent to child? – Rebai Ahmed Mar 16 '22 at 10:51
  • Sorry for late reply. @RebaiAhmed yes. I want a return from parent component so i can hide button in child component – SKL Mar 16 '22 at 14:52

0 Answers0