WebStorm: how to clear HTML in quotes in JavaScript file

I have the following block in a file app.component.ts:

    @Component({
    selector: 'my-app',
    template: `
        <h1>{{title}}</h1>
        <h2>My Heroes</h2>
<ul class="heroes">
  <li>
    <!-- each hero goes here -->
  </li>
</ul>
    <h2>{{hero.name}} details!</h2>
    <div><label>id: </label>{{hero.id}}</div>
    <div>
    <label>name: </label>
    <input [(ngModel)]="hero.name" placeholder="name">
    </div>
    `
})

How can I tell WebStorm to prefix my JS as well as the HTML that is inside quotes?

I already tried: Code > Auto-indent LinesandCode > Reformat Code

I am using WebStorm 2016.3

+4
source share
1 answer

You can use the Edit Angular2HTML Fragmentintent:

enter image description here

To pick it up, simply click Ctrl+Enteron the line. It will open an editor where you can prefix the code, and the changes will be reflected in the line.

+5
source

Source: https://habr.com/ru/post/1661032/


All Articles