1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Angular2 component p-multiSelect Primeng

Discussão em 'Angular' iniciado por aimprogman, Outubro 9, 2024 às 10:22.

  1. aimprogman

    aimprogman Guest

    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 ?

    Continue reading...

Compartilhe esta Página