目前在没有使用额外扩展的情况下是这么解决的
templateUrl
所在的行按 F12 键会跳转到 .html 模版文件,在 styleUrls
所在的行按 F12 键会跳转到样式文件go to component
设置 Ctrl + Shift + F12
快捷键,在 .html 模版文件中按这个快捷键会跳转 .ts 文件Angular Language Service 扩展除了针对 .html 文件提供 go to component
命令,还针对 .ts 文件提供了 go to template
命令,给这个命令也加上 Ctrl + Shift + F12
快捷键,再给这两个同样的快捷键加上 When
触发条件,就可以通过快捷键方便地在 .ts 与 .html 文件之间来回切换
[
{
"key": "ctrl+shift+f12",
"command": "angular.goToComponentWithTemplateFile",
"when": "editorLangId == html"
},
{
"key": "ctrl+shift+f12",
"command": "angular.goToTemplateForComponent",
"when": "editorLangId == typescript"
}
]