问题描述
我想使用Angular 2扩展PrimeNg中的组件.我尝试了一个简单的示例来扩展MultiSelect组件,但未成功.我收到以下错误"DomHandler没有提供者!"在浏览器控制台中.有没有人尝试扩展PrimeNg组件.甚至有可能.
I would like to extend a component in PrimeNg using Angular 2. I tried a simple example to extend the MultiSelect component and was unsuccessful. I am getting the below error "No provider for DomHandler!" in the browser console. Has anyone tried extending the PrimeNg components. Is it even possible.
确切的例外:<>例外:./AppComponent类AppComponent中的错误-内联模板:0:0,由于:没有DomHandler的提供者!
ErrorHandler.handleError @ error_handler.js:54
(匿名)@ application_ref.js:261
ZoneDelegate.invoke @ zone.js:330
onInvoke @ ng_zone.js:273
ZoneDelegate.invoke @ zone.js:329
Zone.run @ zone.js:126
(匿名)@ zone.js:679
ZoneDelegate.invokeTask @ zone.js:363
onInvokeTask @ ng_zone.js:264
ZoneDelegate.invokeTask @ zone.js:362
Zone.runTask @ zone.js:166
rainMicroTaskQueue @ zone.js:529"
The exact exception:<>"EXCEPTION: Error in ./AppComponent class AppComponent - inline template:0:0 caused by: No provider for DomHandler!
ErrorHandler.handleError @ error_handler.js:54
(anonymous) @ application_ref.js:261
ZoneDelegate.invoke @ zone.js:330
onInvoke @ ng_zone.js:273
ZoneDelegate.invoke @ zone.js:329
Zone.run @ zone.js:126
(anonymous) @ zone.js:679
ZoneDelegate.invokeTask @ zone.js:363
onInvokeTask @ ng_zone.js:264
ZoneDelegate.invokeTask @ zone.js:362
Zone.runTask @ zone.js:166
drainMicroTaskQueue @ zone.js:529 "
推荐答案
可以,但是无法扩展模板.
It is possible, but there is no way to extend template.
要解决此错误,您需要在 constructor
中提供MultiSelect组件的所有依赖项:
To fix this error you need to provide in constructor
all dependencies for MultiSelect component:
constructor(el:ElementRef,domHandler:DomHandler,渲染器:Renderer,不同之处:IterableDiffers){super(el,domHandler,渲染器,不同);}
这篇关于扩展PrimeNG中的组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!