我正在将Angular 1.6应用程序升级到Angular 4.
我正在使用UpgradeComponent将angular.module.component的组件定义升级到Angular 4.
我正在使用UpgradeComponent将angular.module.component的组件定义升级到Angular 4.
这是Angular 1.6组件定义
module.component('my-comp',{ bindings: { configuration: '=',name: '=?' },templateUrl: 'templates/my-comp.template.html',controller: 'myCompController',controllerAs: 'myComp',bindToController: true } );
这是升级组件的定义
import { Directive,ElementRef,Injector,SimpleChanges } from '@angular/core'; import { UpgradeComponent } from '@angular/upgrade/static'; @Directive({ selector: 'my-comp' }) export class MyCompDirective extends UpgradeComponent { constructor(elementRef: ElementRef,injector: Injector) { super('myComp',elementRef,injector); } }
问题是当我在Angular 4模板中使用此升级组件时,我收到错误:不支持异步加载指令模板.
This is the angular source code producing this error.
建议的方法是什么来克服这个问题?
我们所有的组件都使用外部模板.