简体   繁体   English

Visual Studio 2015 Angular2 HTML变量智能感知/编译检查

[英]Visual Studio 2015 Angular2 html variable intellisense / compile checks

Is there any way to enable intellisense or at least compile time static checks on visual studio 2015 in html files with angular 2 (NOT angular 1) variables? 有什么方法可以在Visual Studio 2015中启用带有角度2(非角度1)变量的html文件中的Intellisense或至少在Visual Studio 2015上进行编译时静态检查吗?

For example if you have the following typescript somewhere: 例如,如果某处有以下打字稿:

export class Hero {
    constructor(
      public id:number,
      public name:string) { }
}

And for example if you have the following in your html: 例如,如果您的html中包含以下内容:

  <h1>{{title}}</h1>
  <h2>My favorite hero is: {{myHero}}</h2>
  <p>Heroes:</p>
  <ul>
      <li *ng-for="#hero of heroes">
          {{ hero.name }}
      </li>
  </ul>

Then I would like intellisense or at least compile checks on the usage of that hero object and its properties. 然后,我想要智能感知或至少编译对该英雄对象及其属性的用法的检查。 If I type "hero." 如果我输入“ hero”。 then I would like to be able to get the "name" property as a suggestion (or if not possible something that can check at compile time whether these properties and classes exist). 那么我希望能够获得“名称”属性作为建议(或者,如果不可能的话,可以在编译时检查这些属性和类是否存在)。

Is something like that already available? 这样的东西已经可用了吗?

Is something like that already available? 这样的东西已经可用了吗?

Not at the moment. 现在不行。 There might be something after they have template precompilation working : https://docs.google.com/document/d/11r8IuS4xDyhVSEBp7fDYo7aiLYsLEXKs4lPd36umUGM/edit 他们进行模板预编译后,可能会遇到一些问题https : //docs.google.com/document/d/11r8IuS4xDyhVSEBp7fDYo7aiLYsLEXKs4lPd36umUGM/edit

Of course you can use React/TSX quite easily. 当然,您可以很轻松地使用React / TSX。 https://basarat.gitbooks.io/typescript/content/docs/jsx/tsx.html https://basarat.gitbooks.io/typescript/content/docs/jsx/tsx.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM