Unresolved variable or type in html

 I'm using Angular v4.3.1 and whenever I import a service into my component and use it in the html template, the service name says that it is 'Unresolved variable or type', but the code functions correctly. It still autocompletes as well. I feel as if I'm just missing a setting somewhere but am unsure of what it is. 

 

0
4 comments

what Webstorm version do you use? did you try invalidating caches (File | Invalidate caches, Invalidate and restart)?

If the issue persists, please provide code snippets (as text)/files that can be used to recreate the issue. Snippets should include your service definition and usages

0
Avatar
Permanently deleted user

I realized that the names were being set in the constructor so that when I changed them to public instead of private I can now see them in the html files. This didn't work until after I invalidated the caches. Thank you so much! 

2

I see:) private members are indeed not resolved in templates - see https://youtrack.jetbrains.com/issue/WEB-23606.

Using private members in templates should normally be avoided (see the answer in Angular2 Google Group: https://groups.google.com/forum/#!msg/angular/D_O_1fqA9WQ/pRNQARRiBgAJ; see also https://github.com/angular/angular/issues/11978). Template is not a part of the component class, so a template can only access to public properties from the component.

0
Avatar
Permanently deleted user

Thank you so much Elena, 

We've been working in a world of coincidence and misunderstanding and this really clarified a lot of our misconceptions.

Thank you for all of your help :D

1

Please sign in to leave a comment.