Reputation: 6358
I have an array of PrimeNg selectButtons and need to show the first one as pressed. Not finding any guidance on that. Anyone know of the API to do this?
Upvotes: 2
Views: 7201
Reputation: 7068
You just need to initialize the value of 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'}
]
}
}
Upvotes: 6