Angular 4 template error: 'anonymous' does not contain such a member

Viewed 3924

Angular 4 written in Typescript 2.3.4

component.ts

/**
 * Info that drives the tabs in the template. Array is filled
 * in ngOnInit() once data is received from the server
 */
public tabs:Array<{
  title:string,
  description:string,
  data:Array<{name:string}>
}>=[];

component.html

<section *ngFor="let t of tabs">
  ...
  <div *ngFor="let i of t.data">{{i.name}}</div>
                                  ^^^^^^
</section>

Compiler error

Angular: Identifier 'name' is not defined. <anonymous> does not contain such a member

At first I thought this was linked to my other issue but this is different because there is no ambiguity in the shape of the tabs model: the component clearly shows that name is a property of each member of the data array, itself a property of each member of tabs array.

What's going on here?

2 Answers

solution worked !

that gives me this message :

Identifier 'question' is not defined. '' does not contain such a member

plus underline this

<div class="card-header">
          {{q.question}}  <!- underline this line with red color -->
            ^^^^^^^^^^
</div>

it's a typescript problem and you have to declare tabs as an any type to avoid this problem
tabs : any [];

Related