1
Angular2の基本についてはangular tutorialに従っていますが、現在はTypescriptでのみ利用可能なので、javascriptに変換しようとしています。外部ファイルのAngular2ロードコンポーネント
私は現在、app.component.jsとhero-detail.component.jsの2つのファイルを持っています。 app.component.jsにあり、私は自分のAppComponentを持っています。これから、hero-detail.component.jsのコンポーネントをディレクティブとしてロードしたいと思います。
私の現在のコードは次のように見えますが、私はHeroDetailComponentロードする方法を見つけ出すことはできません:JavaScriptで
app.AppComponent =
ng.core.Component({
selector: 'my-app',
inputs : ['hero'],
directives: [HeroDetailComponent],
template: `<h1>{{title}}</h1>My Heroes<h2></h2>
<ul class="heroes">
<li *ngFor="let hero of heroes"
[class.selected]="hero === selectedHero"
(click)="onSelect(hero)">
<span class="badge">{{hero.id}}</span> {{hero.name}}
</li>
</ul>
<my-hero-detail [hero]="selectedHero"></my-hero-detail>
`
})
.Class({
constructor: function() {
this.title = 'Tour of Heroes'
this.heroes = HEROES
this.selectedHero = null
},
onSelect(hero) { this.selectedHero = hero; }
});
})(window.app || (window.app = {}));enter code here
https://angular.io/docs/のような、新しく作成された
HeroDetailComponent
を追加し、あなたのAppComponent
であなたのindex.html
にファイルを含めるようにしてくださいjs/latest/quickstart.html。公式ガイドは、typescript、JS、Dartで利用できます。 '5 MIN QUICKSTART'の下にドロップダウンメニューがあります。 –
@PriyeshKumar JSのドキュメントは空白です – iGbanam
@ Yaskyどこを見ているのかわかりませんが、ドキュメントはすべてドキュメントがあります –