2017-05-04 4 views
0

私は、モーダルコンポーネントを動的に作成し、ボディまたはルート要素にコンポーネントを追加したいと考えています。角2アプリケーションのViewContainerRefを取得

コンポーネントを動的に追加する必要がある場合は、ViewContainerRefが必要です。例えば

:ルートコンポーネントにコンポーネントを追加する方法

createComponent(type) { 
    this.container.clear(); 
    const factory: ComponentFactory = this.resolver.resolveComponentFactory(AlertComponent); 
    this.componentRef: ComponentRef = this.container.createComponent(factory); 
    } 

答えて

0

ルートコンポーネントのhtmlファイルにセレクタを使用する

関連する問題