1

I have an Angular template that needs to call function by passing an index. There is a Codelyzer rule "template-no-call-expression" that complains when I do this.

I have attempted to disable the rule in the typescript file, but it continues to fail the lint check. Is this a bug, or am I not doing it correctly?

/* tslint:disable: template-no-call-expression */
@Component({
...
theMayer
  • 15,456
  • 7
  • 58
  • 90

1 Answers1

3

Make sure the tslint-disabling is the FIRST line in your component.ts (so that means: above the imports)! I had the same problem and after reading the comment on the pull request below, I realized that if you put the disabling on line 17 of your TS, it will disable the check for all lines 17+ in your HTML file, but NOT for line 1 - 16 :\

See comment on https://github.com/mgechev/codelyzer/pull/492

Stephanie
  • 508
  • 5
  • 14
  • I'm confused by your answer - you don't specify rules in the `component.ts` file – theMayer Jan 09 '20 at 16:46
  • In your question, you put `/* tslint:disable: template-no-call-expression */` above your @Component in your TS file to disable the tslint check for your corresponding HTML right? The solution was to move the `/* tslint:disable: template-no-call-expression */` to the FIRST rule = line number of your TS file. Maybe my use of the word "rule" for both "line number" and "tslint rule" caused the confusion, sorry for that :) – Stephanie Jan 10 '20 at 08:01
  • OK, I'l give that a try. – theMayer Jan 10 '20 at 13:17