0

I am developing a simple Angular 6 application. At a certain point a 'Template parse error' appeared, literally out of nowhere: "let-" is only supported on ng-template elements. I don't use any template or ng-template in my code. Anybody with an idea?

Uncaught Error: Template parse errors:
"let-" is only supported on ng-template elements. ("
  </thead>
  <tbody>
    <template ngFor [ngForOf]="rows" [ERROR ->]let-rowz="$implicit" let-index="index">
      <tr *ngIf="!(datePicker.onlyCurrentMonth && rowz[0].sec"): ng:///DatepickerModule/DayPickerComponent.html@38:37
"let-" is only supported on ng-template elements. ("
  </thead>
  <tbody>
    <template ngFor [ngForOf]="rows" let-rowz="$implicit" [ERROR ->]let-index="index">
      <tr *ngIf="!(datePicker.onlyCurrentMonth && rowz[0].secondary && rowz[6].sec"): ng:///DatepickerModule/DayPickerComponent.html@38:58
    at syntaxError (compiler.js:2547)
    at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:19495)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:25041)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:25028)
    at compiler.js:24971
    at Set.forEach (<anonymous>)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:24971)
    at compiler.js:24881
    at Object.then (compiler.js:2538)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:24880)
1
  • please show the code snippets. Commented May 28, 2019 at 12:50

1 Answer 1

1

If I'm not wrong you are using an *ngFor and you are trying to get the index and if that's the case try following the below example.

<div *ngFor="let element of array; let $index = index">{{$index}}</div>

And I think what you are doing is let-index = index;, which I concluded from the error trace you have uploaded. You are using an - between let and index.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.