0

I have an Angular 7 app in PhpStorm and resolution via ctrl click in templates works for everything (Angular specific attributes like *ngIf, custom component tags or pipes) but not for local variables.

For example I have this component:

import { Component } from '@angular/core';

Component({
    selector: 'test-component',
    templateUrl: './test.component.html'
});
export class TestComponent {
    public list: string[];
}

With this template:

<ng-container *ngFor="let x of list">
    Hello {{x}}
</ng-container>

I can ctrl click on the imported module @angular/core to go to the definition, ctrl click on *ngFor to jump to the declarations file, click on {{x}} to jump to the *ngFor/let etc,. but I can NOT click on list to jump to the declaration in the .ts file. It's also rendered in red with the comment "unresolved variable or type".

I have node_modules installed, part of the project and not excluded. All Typescript and Angular autocomplete etc. works, except for template variables.

PhpStorm is 2019.2.3, the Angular plugin is installed and configured. I already have tried invalidate caches, re-index and re-start.

2
  • works fine for me using your (and similar) examples. If the issue persists after caches invalidation (File > Invalidate caches, Invalidate and restart), please create a support ticket, providing a sample project the issue can be reproduced with + idea.log Commented Oct 7, 2019 at 13:23
  • Thanks @lena, I figured it out in the meantime (see below). Commented Oct 7, 2019 at 14:08

1 Answer 1

1

Turns out I had the .html extension assigned to PHP (because I have many legacy files in the project). Curiously all Angular completion mechanics worked except for template variables. Assigning .html to Angular in the File Types area solved the problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.