Mukul Sharma
Mukul Sharma

Reputation: 176

how to display object value of multiselect primeng angular2

I am following this https://www.primefaces.org/primeng/#/multiselect but docs have only information about to print value of a string. how can I display the object value. this.cities.push({label:'New York', value:{id:1, name: 'New York', cityCode: 'NY'}}); for instance i want to display code. I tried {{selectedCity.cityCode}} it is displaying [obj obj]

Upvotes: 0

Views: 2046

Answers (1)

Nehal
Nehal

Reputation: 13307

Since selectedCity is an array, you should use *ngFor to loop through the items.

<div *ngFor="let city of selectedCities">
  <p>{{city.id}}. {{city.cityCode}} - {{city.name}}</p>
</div>

Plunker demo

Upvotes: 1

Related Questions