Codelyzer: Can't resolve template variable in mdAutocomplete

Created on 25 Apr 2017  路  3Comments  路  Source: mgechev/codelyzer

Hi! I have this error after update to 3.0.0 with the mdAutocomplete component

The property "auto" that you're trying to access does not exist in the class declaration.

The code:

<md-input-container>
  <input type="text" mdInput placeholder="Search..." [mdAutocomplete]="auto" />
  <md-autocomplete #auto="mdAutocomplete">
    <md-option *ngFor="let item of options" [value]="item">{{item.name}}</md-option>
  </md-autocomplete>
</md-input-container>

Any idea? thanks!

Most helpful comment

As a workaround, you can instantiate using the @ViewChild decorator on your @Component, like so:

@ViewChild('auto') auto: ElementRef;

All 3 comments

3.0.0 does "flat analysis", i.e. it won't consider the entire project (won't collect the entire metadata for your project) which means that it will not be able to discover the mdAutocomplete template reference.

Take a look at this section for more details. Also, you may consider going back to 3.0.0-beta.x https://github.com/mgechev/codelyzer/issues/191#issuecomment-296697740.

As a workaround, you can instantiate using the @ViewChild decorator on your @Component, like so:

@ViewChild('auto') auto: ElementRef;

thanks @leocaseiro , it works!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fabioemoutinho picture fabioemoutinho  路  5Comments

QuentinFchx picture QuentinFchx  路  3Comments

artaommahe picture artaommahe  路  3Comments

Umayalmuthupalaniappan picture Umayalmuthupalaniappan  路  5Comments

snebjorn picture snebjorn  路  5Comments