The template context does not define a member called 'item'
See original GitHub issueDescribe the bug
Not sure if this issue is related to this extension, but the code does compile and work even if the language service gives me an error in the console.
In a component.html file I have this:
<ng-template ng-label-tmp ng-option-tmp let-item="item">
{{ item.name }} -- {{ item.description }} -- {{ item.price | currency }}
</ng-template>
the let-item="item"
piece is red highlighted and this is the description:
The template context does not define a member called ‘item’
To Reproduce
Use any *-tmp
directives along with let-*
ones.
Expected behavior
No Errors should be highlighted for the let-item="item"
directive.
Logs
- Console output
[Info - 17:40:22] Angular language server process ID: 21305
[Info - 17:40:22] Using typescript v3.7.4 from /home/user/.vscode/extensions/angular.ng-template-0.900.5/node_modules/typescript/lib/tsserverlibrary.js
[Info - 17:40:24] Using @angular/language-service v9.0.0-rc.9 from /home/user/.vscode/extensions/angular.ng-template-0.900.5/server/node_modules/@angular/language-service/bundles/language-service.umd.js
[Info - 17:40:25] Log file: /home/user/.config/Code/logs/20200123T153034/exthost9/Angular.ng-template/nglangsvc.log
[Error - 17:40:39] No config file for /home/user/git/projects/my-app/src/app/ui-widgets/app-card/add-item-card/add-item-card.component.html
- Log file nglangsvc.log
Additional context
If I remove both ng-label-tmp
and ng-option-tmp
directives the error disappears.
UPDATE
Downgrading the extension to v0.900.4
the message error disappears.
The v0.900.5
starts to show this error.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:17 (7 by maintainers)
Top Results From Across the Web
ng-template Error: The template context does not define a ...
So Visual Studio Code gives me the error for the 3 parameters of the ng-template . However, when compiled the placeholder does show...
Read more >The "The template context of 'DxTemplateDirective' does not ...
The "The template context of 'DxTemplateDirective' does not define an implicit value" error occurs in an Angular project.
Read more >Template context of 'DataTableColumnCellDirective' does not ...
Hello, I am getting an error with the ng-template element, ... of 'DataTableColumnCellDirective' does not define a member called 'row' #860 ...
Read more >Chapter 4, Understanding and Using Angular Components
Again, just like templates, Angular will not pull in these styles at runtime, ... Thus, any element that adds the name class to...
Read more >NgTemplateOutlet - Angular
Using the key $implicit in the context object will set its value as default. @Input() ngTemplateOutlet: TemplateRef<any> | null. A string defining the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@fdinardo okay, the PR above (https://github.com/angular/angular/pull/35036) will make this a warning 🙂
When diagnostics are performed in the language service, the context for the embedded view is assumed to be the context of the structural directive that is applied to
ng-template
. This assumption is incorrect, according to the docs in angular.io: