Questions tagged «angular2-compiler»

14
如何使用/创建动态模板以使用Angular 2.0编译动态组件?
我想动态创建一个模板。这应该用于ComponentType在运行时和位置构建一个(甚至替换)在托管组件内部。 在使用RC4之前ComponentResolver,使用RC5时会收到以下消息: ComponentResolver is deprecated for dynamic compilation. Use ComponentFactoryResolver together with @NgModule/@Component.entryComponents or ANALYZE_FOR_ENTRY_COMPONENTS provider instead. For runtime compile only, you can also use Compiler.compileComponentSync/Async. 我找到了此文档(Angular 2同步动态组件创建) 并了解我可以使用 一种动态ngIf的ComponentFactoryResolver。如果我在内部传递了已知组件@Component({entryComponents: [comp1, comp2], ...})-我可以使用.resolveComponentFactory(componentToRender); 实时运行时编译,具有Compiler... 但是问题是如何使用它Compiler?上面的说明说我应该打电话给:Compiler.compileComponentSync/Async -那怎么办? 例如。我想(基于某些配置条件)为一种设置创建这种模板 <form> <string-editor [propertyName]="'code'" [entity]="entity" ></string-editor> <string-editor [propertyName]="'description'" [entity]="entity" ></string-editor> ... 在另一种情况下,这个(string-editor被替换为text-editor) <form> <text-editor …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.