Angular2의 기본 사항 인 angular tutorial을 따르고 있습니다. JavaScript는 현재 Typescript에서만 사용 가능하므로이 파일을 javascript로 변환하려고합니다.Angular2 자바 스크립트를 사용하는 외부 파일의로드 구성 요소
현재 app.component.js와 hero-detail.component.js의 두 파일이 있습니다. app.component.js에 있습니다. AppComponent가 있습니다. 여기에서 hero-detail.component.js의 구성 요소를 지시문으로로드하고 싶습니다.
나의 현재 코드는 다음과 같습니다,하지만 난 HeroDetailComponent을로드하는 방법을 알아낼 수 없습니다 :
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/에서 파일을 포함해야합니다 js/latest/quickstart.html. 공식 가이드는 타이프 스크립트, JS 및 다트로 제공됩니다. '5 MIN QUICKSTART' 제목 아래에 드롭 다운 메뉴가 있습니다. –
@PriyeshKumar JS에 대한 문서가 비어 있습니다. – iGbanam
@ Yasky 어디서 보는지 모르겠지만, 저에게 설명서에는 모든 것이 있습니다. –