0

I have HTML view like below where user's roles are checked. I would like to bind table of changed user's roles using actualizeRoles() method. How can I do that?

<md-accordion class="example-headers-align">
        <md-expansion-panel hideToggle="true" *ngFor="let userRole of userRoles">
            <md-expansion-panel-header>
                <md-panel-title>
                    {{userRoles.UserName}}
                </md-panel-title>
                <md-panel-description>
                    {{userRoles.RoleName}}
                </md-panel-description>
            </md-expansion-panel-header>
            <div *ngFor="let role of roles">
                <div>
                    <input type="checkbox" [checked]="userRoles.RoleIds == role.Id">{{r.Name}}
                </div>
            </div>
            <md-action-row>
                <button md-button color="primary" (click)="actualizeRoles()>Approve</button>
            </md-action-row>
        </md-expansion-panel>
    </md-accordion>

This is user's roles model below where RoleIds[] has a table of Ids roles.

export class UserRole {
    UserId: number;

    Name: string;

    RoleName: string;
    RoleIds: number[];
}

1 Answer 1

1

Simple solution:

<input type="checkbox" [(ngModel)]="variable">

You can read more here:

Angular 2 Checkbox Two Way Data Binding

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.