Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Toggling the visibility of a component with an Input function in Angular

I have a component that accepts a callback function @Input() closeCallback: () => void;

and calls it in a close function like this :

  close() {
    this.closeCallback();
  }
<button class="close" (click)="close()">
        <img src="assets/img/share/icon_close_dark.svg" />
    </button>

So in the parent component I passed a function to it :

<ng-container  *ngIf="isPopupOpen">
<e2-fullscreen-popup
  [title]="'top promotions'"
  [closeCallback]="closePopup"
  >
...
</e2-fullscreen-popup>
</ng-container>
  closePopup() {
   
    this.isPopupOpen = false;
    console.log('this.isPopupOpen',this.isPopupOpen);
  }

so why I'm not able to remove the component when clicking on the button, even thou the logs themselves show that this.isPopupOpen is false?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

@Input is used to pass data to the child component; to implement a callback you need to use @Output.

In your child component:

@Output() closeCallback = new EventEmitter();

// ...

close() {
  this.closeCallback.emit();
}

In your parent component:

<ng-container  *ngIf="isPopupOpen">
<e2-fullscreen-popup
  [title]="'top promotions'"
  (closeCallback)="closePopup($event)"
  >
...
</e2-fullscreen-popup>
</ng-container>
closePopup(dataFromChild: any){
  // handle callback
  this.isPopupOpen = false;
  console.log('this.isPopupOpen',this.isPopupOpen);
}

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!