PrimeNg selectButton:如何显示一个选定
问题描述:
我有一个PrimeNg selectButtons数组,需要显示第一个按下的按钮。 没有找到任何指导。 任何人都知道的API来做到这一点?PrimeNg selectButton:如何显示一个选定
答
你只需要初始化ngModel [(ngModel)]="selectedCity"
的价值
@Component({
selector: 'my-app',
template: '<p-selectButton [options]="cities" [(ngModel)]="selectedCity"></p-selectButton>'
})
export class AppComponent {
selectedCity = 'London';
cities: any[];
ngOnInit() {
this.cities = [
{label:'London', value:'London'},
{label:'Istanbul', value:'Istanbul'},
{label:'Paris', value:'Paris'}
]
}
}
我有这样的线下降为我的测试,以真正了解的代码,果然我打破了部分代码:(谢谢 – reza