问题
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