Vscode-ng-language-service: Support optional chaining in template

Created on 28 Oct 2018  路  6Comments  路  Source: angular/vscode-ng-language-service

I use reactive form i create a method called displyFiledError it take filed name and return ValidationErrors so i can access it in template but i got an error

[Angular] Identifier 'email' is not defined. '__type' does not contain such a member

fun
html

even in typescript there is no suggestions but no error in run type

bug

Most helpful comment

same here.
image

VSCode version:

Version: 1.30.2 (system setup)
Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
Date: 2019-01-07T22:54:13.295Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
OS: Windows_NT x64 10.0.17134

It can be solved by adding !! like in example below, before expression, but in my case I don't need true or false as return statement

image

Found solution here: https://stackoverflow.com/a/49880644/7986808

<em *ngIf="abstract.invalid && abstract.dirty && !!abstract?.errors.restrictedWords">Restricted words found:
        {{abstract.errors['restrictedWords']}}</em>

All 6 comments

As an addition to this.
image
image

I have the same issue using reactive forms

I have the same issue using angular 6 reactive forms validation.

untitled

same here.
image

VSCode version:

Version: 1.30.2 (system setup)
Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
Date: 2019-01-07T22:54:13.295Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
OS: Windows_NT x64 10.0.17134

It can be solved by adding !! like in example below, before expression, but in my case I don't need true or false as return statement

image

Found solution here: https://stackoverflow.com/a/49880644/7986808

<em *ngIf="abstract.invalid && abstract.dirty && !!abstract?.errors.restrictedWords">Restricted words found:
        {{abstract.errors['restrictedWords']}}</em>

This is similar to https://github.com/angular/vscode-ng-language-service/issues/149, will track issue there.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings