Prime NG multi select初始化值无法看到已选中复选框

时间:2019-03-22 14:26:48

标签: primeng primeng-dropdowns

Prime NG多选初始化值看不到选中的复选框

init方法

  this.cities =  [
  {label: 'New York', value: 'NY'},
  {label: 'Rome', value: 'RM'},
  {label: 'London', value: 'LDN'},
  {label: 'Istanbul', value: 'IST'},
  {label: 'Paris', value: 'PRS'}];

让我们选择T:国家[];

selectedT = [{label:“罗马”,值:“ RM”}];

this.dForm.controls [“ selectedCities”]。setValue([{{label:“ Rome”,value:“ RM”}]);

  

1 个答案:

答案 0 :(得分:0)

无需将整个对象传递给“ selectedCities”数组。将唯一的值传递给数组。

selectedT = ["RM"];

this.dForm.controls["selectedCities"].setValue(["RM"]);