Issue
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?
Solution
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'}
]
}
}
Answered By - Kld
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.