Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go To Definition in angular html file in Visual Studio Code

Is it possible, maybe with an extension, to use Go To Definition (F12) when editing an html file of an Angular project?

Let's assume, in sample.html:

<input matInput class="app-input" placeholder="InputName" [(ngModel)]="myNodel.name">  ...  <button mat-mini-fab class="plus"   (click)="myMethod()"   <mat-icon>arrow_forward</mat-icon> </button> 

I would like to navigate to "myMethod() ..." in sample.ts, or navigate to the field of the model, to the line "name: string;" in my-model.ts, as the function normally works with .ts files.

like image 406
gerleim Avatar asked Nov 10 '17 12:11

gerleim


People also ask

How do you jump to define in VS Code?

Go to Definition# Tip: You can jump to the definition with Ctrl+Click or open the definition to the side with Ctrl+Alt+Click.

What is go to definition in Visual Studio?

In Visual Studio, the Go To Definition and Peek Definition features enable you to easily view the definition of a type or member. If the source code is not available, metadata is displayed instead.

How do I select HTML language in Visual Studio Code?

Go to the Extensions view (Ctrl+Shift+X) and type 'html' to see a list of relevant extensions to help with creating and editing HTML.


1 Answers

You can do this with the extension

Angular Language Service extension for VS Code.

which has the feature

This extension provides a rich editing experience for Angular templates, both inline and external templates including:

Completions lists

AOT Diagnostic messages

Quick info

Go to definition

Angular Language Service - A handy extension for angular developers

like image 139
Sajeetharan Avatar answered Sep 28 '22 03:09

Sajeetharan