2016-09-01 3 views
4

私は、アプリケーションで動的にコンポーネントを読み込むために以下のコードを使用しました。ご存知のように、compileComponentAsyncはRC6では廃止されました。私は同様の解決策を探したい。おそらく、私はcompileModuleAsyncを使うべきです。しかし、私は何かを見つけることができませんでした。誰にもアイデアはありますか?動的コンポーネント読み込みのための非推奨compileComponentAsyncと同等

this.compiler.compileComponentAsync(component) 
    .then(factory => { 
     const injector = ReflectiveInjector.fromResolvedProviders([], this.vcRef.parentInjector); 
     this.vcRef.createComponent(factory, 0, injector, []); 
... ... 
+1

も参照してください。http://stackoverflow.com/questions/38888008/how-can-i-use-create-dynamic-template-to-compile-component-with-angular2-rc5/38888009#38888009 –

答えて

6

compileModuleAndAllComponentsAsyncあなたはModuleWithComponentFactoriesを返します。

this.compiler.compileModuleAndAllComponentsAsync(module).then(_module => { 
      _module.componentFactories => Gives factory for all the components which are exported from the module. 
     }); 

Read more about it here

この情報がお役に立てば幸いです!

関連する問題