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

185
Views
Error calling (click) function inside ngIf else template

I have an *ngIf with an else template defined as such:

<button type="button" *ngIf="!paused; else resume" (click)="pause()">
    pause
</button>

<ng-template #resume>
    <button type="button" (click)="resume()">
        resume  
    </button>
</ng-template>


class AppComponent  {
    paused = false;
    pause() {
        this.paused = true;
    }
    resume = () => {
        this.paused = false;
    }
}

The pause button works, but clicking the resume button will log a console error:

Error: jit_nodeValue_4(...) is not a function

Here is a runnable demo of the issue. Click the 'Resume' button and check console for errors.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The name of the inline template resume conflicts with the method name resume. The template basically overwrites the method, hence the error.

If you change the template name, it will work:

<button type="button" *ngIf="!paused; else resumeTpl" (click)="pause()">
  pause
</button>

<ng-template #resumeTpl>
  <button type="button" (click)="resume()">
    resume  
  </button>
</ng-template>
over 4 years ago · Santiago Trujillo 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!