angular - 尝试在应用程序中使用 PrimeNG 中的 p-Dropdown 时出错
问题描述
我想在我的应用程序中使用这个 PrimeNG-Dropdown。所以我做了什么:
npm i primeng --save
然后我DropdownModule
在我的导入中添加了app.module.ts
. 之后,我在我的 html 中包含了以下代码:
<p-dropdown [options]="optionList" [(ngModel)]="selectionString" placeholder="Choose one"></p-dropdown>
在运行ng serve
和启动localhost:4200
时出现以下错误:
./node_modules/primeng/components/multiselect/multiselect.js 未找到模块:错误:无法解析 '%projectroot%\node_modules\primeng\components\multiselect' 中的 '@angular/cdk/scrolling'
我还尝试从imports
-Array 中删除导入,这导致了不同的错误。我究竟做错了什么?我正在使用 Angular 7 顺便说一句。
删除导入时出现以下错误:
Can't bind to 'options' since it isn't a known property of 'p-dropdown'.
1. If 'p-dropdown' is an Angular component and it has 'options' input, then verify that it is part of this module.
2. If 'p-dropdown' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<p-dropdown [ERROR ->][options]="optionList" [(ngModel)]="selectionString" placeholder="Choose one"></p-dropdown"): ng:///AppModule/ProjectGeneratorComponent.html@13:18
'p-dropdown' is not a known element:
1. If 'p-dropdown' is an Angular component, then verify that it is part of this module.
2. If 'p-dropdown' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
[ERROR ->]<p-dropdown [options]="optionList" [(ngModel)]="selectionString" placeholder="Choose one">"):
解决方案
您需要安装 Angular CDK。使用npm install @angular/cdk --save命令。
然后使用在 appModule 中导入多选模块
import {MultiSelectModule} from 'primeng/multiselect';
推荐阅读
- python - 使用日期和时间对 Pandas DataFrame 进行排序
- html - 链接旋转但最终在页面的完全不同的区域?
- reactjs - [React-Context]:表单验证错误第一次没有出现
- java - Apache Flink:为 DataStream API 添加侧输入
- javascript - 如何在里面设置Javascript的变量值
- elasticsearch - docker上的elasticsearch - 快照和恢复 - access_denied_exception
- sql - PostgreSQL 触发器和函数使用三表连接/子查询搜索更新表
- javascript - 从 Node 中的 URL 下载 CSV
- rust - Rust 特征别名
- r - predict.MCMCglmm 错误——给出广泛的非粒度值