primeng autocomplete functionality is not working

痞子三分冷 提交于 2020-01-26 04:43:05

问题


I have added the AutoCompleteModule in app.module.ts file.

import { AutoCompleteModule } from 'primeng/autocomplete';

But autocomplete is not working as expected. I am getting below error:

Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'p-autoComplete'.
1. If 'p-autoComplete' is an Angular component and it has 'ngModel' input, then verify that it is part of this module.
2. If 'p-autoComplete' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

I am using primeng latest version.

I have tried adding autocomplete module in app.module.ts. After this I rebuild the application but still it is giving above error. Any help would be appreciated. Thanks


回答1:


To make it work, you need to add FormsModule in app.module.ts file. Then it will work.

import { FormsModule  } from '@angular/forms'; 



回答2:


use it like this:

<p-autoComplete  ... [(ngModel)]="WHATEVER" ...></p-autoComplete>

That's how you use ngModel with primeng components.



来源:https://stackoverflow.com/questions/58166092/primeng-autocomplete-functionality-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!