在Angular2 RC4中如何将组件添加到预编译数组?

前端之家收集整理的这篇文章主要介绍了在Angular2 RC4中如何将组件添加到预编译数组?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我刚刚将我的Angular2项目更新为RC4,当我打开我的应用程序时,路由器现在正在控制台中发出此警告消息:
router.umd.js:2466 'FrontpageComponent' not found in precompile array.  To ensure all components referred to by the RouterConfig are compiled,you must add 'FrontpageComponent' to the 'precompile' array of your application component. This will be required in a future release of the router.

我试图弄清楚我需要做什么来解决这个问题,但由于文档稀疏,我找不到答案。这是什么预编译数组,哪里可以找到它,或者如何添加它?

在较新的路由器版本中,这不应该是必要的。

< = RC.4 这只是@Component()或@Directive()装饰器的一个附加参数:

@Component({
  selector: '...',template: '...',directives: [FrontpageComponent],precompile: [FrontpageCmponent]
})

https://github.com/angular/angular/blob/6c5b653593eff19c5b9342b2cf0195aca49379cb/modules/%40angular/core/src/metadata/directives.ts#L968

/** * Defines the components that should be precompiled as well when * this component is defined. For each components listed here,* Angular will create a {@link ComponentFactory ComponentFactory} and store it in the * {@link ComponentFactoryResolver ComponentFactoryResolver}.

原文链接:https://www.f2er.com/angularjs/144858.html

猜你在找的Angularjs相关文章