gpt4 book ai didi

angular - 尝试在应用程序中使用 PrimeNG 中的 p-Dropdown 时出错

转载 作者:太空狗 更新时间:2023-10-29 19:36:21 32 4
gpt4 key购买 nike

我想使用 this PrimeNG-Dropdown在我的申请中。所以我做了什么:

npm i primeng --save

然后我在从 app.module.ts 导入的文件中添加了 DropdownModule。之后,我在我的 html 中包含了以下代码:

<p-dropdown [options]="optionList" [(ngModel)]="selectionString" placeholder="Choose one"></p-dropdown>

在运行 ng serve 并启动 localhost:4200 时,出现以下错误:

./node_modules/primeng/components/multiselect/multiselect.js Module not found: Error: Can't resolve '@angular/cdk/scrolling' in '%projectroot%\node_modules\primeng\components\multiselect'

我还尝试从 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';

关于angular - 尝试在应用程序中使用 PrimeNG 中的 p-Dropdown 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53888193/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com