简体   繁体   中英

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?

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:

  <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." 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

Of course you can use React/TSX quite easily. https://basarat.gitbooks.io/typescript/content/docs/jsx/tsx.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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