mardi 5 mars 2019

Bind CheckBox list from ID in angular 6

I am using a checkBox list here is my list

   <div *ngFor="let x of rolesArr">
   <input type="checkbox" value="" (change)="changeModel($event, rolesArr, x.Id)" [(ngModel)]="x.checked" formControlName="Roles" />
 <label></label>
</div>

and the array which i am using it to bind is

this.rolesArr = [
            { Id: 1, Name: 'Role-Send Push Notification'},
            { Id: 2, Name: 'Role-Course Creation and Preview'},
            { Id: 3, Name: 'Role-Course Publishing'},
            { Id: 4, Name: 'Role-Mobile User Management'},
        ];

I am saving the comma seperated values into database and while i am getting the vales i am unable to bind it again I am getting the values like this '1','2' so how can i bind the checkbox list using its Id




Aucun commentaire:

Enregistrer un commentaire