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”}]);
答案 0 :(得分:0)
无需将整个对象传递给“ selectedCities”数组。将唯一的值传递给数组。
selectedT = ["RM"];
this.dForm.controls["selectedCities"].setValue(["RM"]);