简体   繁体   English

如何显示多选质感angular2的对象值

[英]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. 我正在关注这个https://www.primefaces.org/primeng/#/multiselect,但是文档仅包含有关打印字符串值的信息。 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] 我尝试了{{selectedCity.cityCode}},它显示[obj obj]

Since selectedCity is an array, you should use *ngFor to loop through the items. 由于selectedCity是一个数组,因此应使用*ngFor来遍历所有项目。

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

Plunker demo 柱塞演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM