我有一个使用angular-cli构建的角度2应用程序,我需要在我的一个组件中使用角度1指令(从不同的应用程序重用它)。我按照以下步骤进行操作:
但是现在我遇到了这个错误并且无法通过它。我正在使用angular2.0.2(我设法在过去使用beta版本构建了一个混合应用程序,但它是一个angular1应用程序,我使用角度2组件与适配器的降级功能)。
在我的app.module.ts中,我有:
import { UpgradeAdapter } from '@angular/upgrade';
const upgradeAdapter = new UpgradeAdapter(forwardRef(() => AppModule));
const HeroDetail = upgradeAdapter.upgradeNg1Component('heroDetail');
@NgModule({
imports: [
BrowserModule,
...
],
declarations: [
...
HeroDetail
]
})
export class AppModule { }
我的hero-detail.component.ts看起来像这样:
export const heroDetail = {
templateUrl: 'hero-detail.html',
controller: function() {
}
};
我的hero-detail.html看起来像这样:
<h2>Windstorm details!</h2>
我尝试在另一个角度2组件中使用该指令,只需在模板中添加:
当我运行服务时,应用程序编译正常,但是当我尝试加载页面时,我得到了上述错误。
有关如何推进这项工作的任何建议吗?