2017-10-25 3 views
0

은 내가 런타임에 angular2 구성 요소를 만들 그래서처럼 부트 스트랩하려고 바닐라 ES5 스크립트,ES2에서 angular2 구성 요소를 부트 스트랩하는 방법은 무엇입니까?

var mycomp = require('complibrary').mycomponent; 
document.addEventListener('DOMContentLoaded', function() { 
ng.platformBrowserDynamic.bootstrap(mycomp); 
}); 

가 complibrary 우리가 내부적으로 개발 한 별도의 angular2 구성 요소 라이브러리 고려 있습니다. mycomponent는 ES5 코드에서 사용하도록 내 보낸 구성 요소 중 하나입니다. 우리는 롤업을 사용하여 구성 요소의 최종 umd 정의를 뱉어냅니다. 아래에서 mycomponent 발췌 부분을 볼 수 있습니다.

var mycomponent = (function() { 
function mycomponent() { 
    this.name = "Abhang Rane"; 
} 
mycomponent = __decorate([ 
    _angular_core.Component({ 
     selector: 'mycomponent', 
     template: '<h1>{{name}}</h1>' 
    }), 
    __metadata('design:paramtypes', []) 
], mycomponent); 
return mycomponent; 
}()); 

은 각 2.2 및 platformBrowserDynamic에 사용 가능한 부트 스트랩 방법이없는 이상 각 2.0.0.rc1와 함께 일하지만. 최신 앵글 2 빌드로 이것을 달성 할 수있는 방법이 있습니까? 선호하는 구성 요소를 변경하지 않고 ...

답변

0

Angular modules은 AngularJS 모듈의 직계 후계자로서 Angular 2.0.0 RC5에서 소개되었습니다.

platformBrowserDynamic().bootstrapModule(AppModule); 

그리고 부트 스트랩 될 예정이다 구성 요소가 정의 된 각각의 모듈이 있어야합니다 : 그것은 this ES5 example에 표시된 것으로

, 그것은이다

var AppModule = NgModule({ 
    declarations: [AppComponent], 
    bootstrap: [AppComponent] 
}) 
.Class({ constructor: function() {} }); 
+0

감사합니다. 마치 각진 버전을위한 자리 표시 자 모듈이 있어야 할 것 같습니다. – theraneman

관련 문제