3
コンポーネントとそのHTMLファイルがあります。Angular2のビュー内にコンポーネントなしでHTML部分を追加する方法
成分:
ハローworld.component.ts
import {Component} from 'angular2/core';
@Component({
selector: 'hello-world',
templateUrl: 'hello-world.html'
})
export class HelloWorld {
yourName: string = '';
}
テンプレート:
ハローworld.html:
<label>Name:</label>
<h1>Hello {{yourName}}!</h1>
今、私は何のコンポーネントを持っていない他のHTML template.html
、例えばそれが含まれている、
template.html今
<h1>Welcome to template file</h1>
<p> This is an example file </p>
を持って、私はhello-world.html
でtemplate.html
ファイルをインクルードしたかったです。どうやってやるの。私が行うために使用Angular1で
、私はAngular2でそれを行うことができますどのように
<div ng-include src="'template.html'"></div>
?私はAngular2の新機能です。
私は多くの場所でこの質問を検索しましたが、すべてがコンポーネントを持つ回答を出しています。私の必要な解決策は得られませんでした。