1

我正在尝试从我的内部text/ng-template脚本标签中应用 html。但它无法正常工作。如何htmlscript标签申请?

这是我的代码和html:

js部分:

//our root app component
import {Component} from 'angular2/core'

@Component({
  selector: 'my-app',
  providers: [],
  templateUrl: "template.html", //this is the id.
  directives: []
})
export class App {
  public title = "My Title";
  private userName = "Test Name";
  constructor() {
    this.name = 'Angular2'
  }
}

HTML部分:

      <body>
        <my-app>loading...</my-app>
//template declared
        <script type="text/ng-template" id="template.html">

          <h2>{{title}}</h2>
          <div>
            <h2>Hello {{name}}</h2>
            <h2>{{userName}}</h2>
          </div>

        </script>
      </body>

我收到一个错误:

未能加载 template.html

正确的使用方法是什么?

4

1 回答 1

0

不幸的是,Angular 2 不支持,也不会支持:\ https://github.com/angular/angular/issues/6126

于 2016-04-26T20:41:14.670 回答