如何使用/創(chuàng)建動態(tài)模板來編譯具有角2.0的動態(tài)組件?我也想動態(tài)創(chuàng)造模板。這應(yīng)該用于構(gòu)建一個ComponentType在…運行時和地點(甚至替換)它在托管組件的某個地方。直到RC4我用ComponentResolver,但在Rc5中,我得到了信息:ComponentResolver不支持動態(tài)編譯。使用ComponentFactoryResolver連同@NgModule/@Component.entryComponents或者用Analysis_for_entry_Components提供程序代替。僅用于運行時編譯,您也可以使用Compiler.compileComponentSync/Async.我找到了這份(官方的)文件角2同步動態(tài)元件創(chuàng)建明白我可以用任何一種一種動態(tài)ngIf帶著ComponentFactoryResolver。,如果我將已知的組件傳遞到托管@Component({entryComponents: [comp1, comp2], ...})-我可以用.resolveComponentFactory(componentToRender);實際運行時編譯Compiler...但問題是如何使用Compiler?上面的說明說我應(yīng)該打電話給:Compiler.compileComponentSync/Async-那是怎么回事?例如。我想創(chuàng)造(基于某些配置條件)這種模板適用于一種設(shè)置<form>
<string-editor [propertyName]="'code'"
[entity]="entity"
></string-editor>
<string-editor [propertyName]="'description'"
[entity]="entity"
></string-editor>
...在另一種情況下,這個(string-editor被替換為text-editor)<form>
<text-editor [propertyName]="'code'"
[entity]="entity"
></text-editor>
...諸若此類(不同編號/日期/參照)editors)按屬性類型,跳過了某些用戶的一些屬性.)。即。這是一個例子,真正的配置可以生成更多不同和復(fù)雜的模板。這個模板正在改變所以我不能用ComponentFactoryResolver通過現(xiàn)有的.。我需要解決辦法CompilerAOT和JitCompiler(原RuntimeCompiler)您想在AOT(提前編譯)中使用這些特性嗎?你得到的是:錯誤:遇到靜態(tài)解析符號值的錯誤。不支持函數(shù)調(diào)用??紤]將函數(shù)或lambda替換為導(dǎo)出函數(shù)的引用(原始.ts文件中的位置65:17),解析./node_modules/@angular/compiler/src/compiler.d.ts,中的符號編譯器_提供者請留下你的評論,在這里投票:AOT能支持使用編譯器_提供者的/Will/Will代碼嗎?
如何使用/創(chuàng)建動態(tài)模板來編譯具有角2.0的動態(tài)組件?
繁星點點滴滴
2019-05-30 15:37:39