In template user.component.html i use component of Primeng
<p-multiSelect name="roles_id" [(ngModel)]="selectedRoles" [options]="user.roles"></p-multiSelect>
When load the input data, how show selected values
This code in user.component.ts
export class UserComponent implements OnInit {
private selectedStores: string[];
constructor(private roleService: RoleService){
this.roleService.getRoleList().subscribe(response=>{this.user.roles=response.body.data.map(function(value){
return {label:value.name, value: value.id};
});})
this.selectedRoles=['1','2'];
}
ngOnInit() {
this.user={
roles: [],
};
}
}
But in interface multiselect show null,null , if i click multiselect the two items selected. How to show label instead null,null ?