我有一组 PrimeNg 选择按钮,需要将第一个按钮显示为按下状态。没有找到任何指导。任何人都知道执行此操作的 API?
你只需要初始化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'}
]
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3677 次 |
| 最近记录: |