【发布时间】:2023-12-05 03:14:02
【问题描述】:
我迁移到 PrimeNG 6.1.7,但我遇到了 p-dropdown 问题。 这是我在 app.module 中的代码导入(取自一个简单的示例):
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {DropdownModule} from 'primeng/dropdown'; // include this for dropdown support
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
DropdownModule // dropdown support
],
providers: [],
bootstrap: [AppComponent],
schemas:
[]
})
export class AppModule { }
在 app.component.ts 中:
import { Component, OnInit } from '@angular/core';
import {SelectItem} from 'primeng/api';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit{
employes: SelectItem[];
selectedEmploye: any;
constructor(){
this.employes = [
{label:'Select Employee', value:null},
{label:'Franc', value:1},
{label:'Kiran', value:2},
{label:'John', value:3},
];
}
ngOnInit(){
}
}
在 html 中我有:
<p-dropdown employes="" ngmodel="" options="" selectedemploye=""></p-dropdown>
Selected Employee: {{selectedEmploye }}
我还安装了 primeicons e 在 angular.json 中导入了它:
...
"styles": [
"src/styles.css",
"node_modules/primeicons/primeicons.css"
],
...
有什么建议吗? 非常感谢...
【问题讨论】: