2016-11-24 12 views
1

하나의 HTML 페이지에서 여러 개의 angular2 구성 요소를 부트 스트랩하려고합니다.Angular2 속성과 ComponentFactoryResolver 바인딩

<body> 
    <cart id="cart">Loading CartComponent content here ...</cart> 
    <p>The text between components</p> 
    <item [itemId]="1" [itemName]="Cool Item1" id="item-1">Loading ItemComponent id=1 content here ...</item> 
    <p>The text between components</p> 
    <item [itemId]="2" [itemName]="Cool Item2" id="item-2">Loading ItemComponent id=2 content here ...</item> 
    <p>The text between components</p> 
    <item [itemId]="3" [itemName]="Cool Item3" id="item-3">Loading ItemComponent id=3 content here ...</item> 

    </body> 

이제까지 서버에서 index.html로 전달 된 속성의 속성 바인딩을 제외하고는 모든 것이 잘 작동합니다.

다음은 일반적으로 Angular2에서 지원하지 않는 plunker 루트 요소 태그에 바인딩 https://plnkr.co/edit/5DbVda?p=preview

답변

2

입니다.

당신은

export class AppComponent { 
    constructor(elementRef:ElementRef) { 
    console.log(elementRef.nativeElement.getAttribute('inputField)); 
    } 
} 

Initialize Angular 2 component with attribute

를 참조하여 해결할 수 있습니다