首页 > 解决方案 > PrimeNG 下拉按钮没有反应/正常工作

问题描述

因此,我正在关注本教程,了解如何实现 Prime ng 下拉按钮:https ://www.primefaces.org/primeng/showcase/#/dropdown

我按照教程操作,设计的下拉按钮显示为“纽约”。但是当我点击它时,什么也没有发生。我希望它会下拉并向我显示其他选项,但没有任何反应。我也安装了 angular/cdk。

我的html:

<p-dropdown [options]="cities" [(ngModel)]="selectedCityCode" optionLabel="name" optionValue="code"></p-dropdown>

我的 ts(缩短):

interface City {
  name: string,
  code: string
}

cities: City[];

selectedCityCode: string;

constructor() {
  this.cities = [
    {name: 'New York', code: 'NY'},
    {name: 'Rome', code: 'RM'},
    {name: 'London', code: 'LDN'},
    {name: 'Istanbul', code: 'IST'},
    {name: 'Paris', code: 'PRS'}
  ];
}

我究竟做错了什么?

标签: angularprimeng

解决方案


噗,这很有趣。BrowserAnimationsModule显然我的module.ts 中没有导入。导入后,一切正常。


推荐阅读