在[checked]条件

时间:2017-10-24 13:49:01

标签: angular typescript

如何迭代RoleIds数组以检查条件并选中用户角色的ID与role数组中的角色ID相同的复选框?

<md-accordion class="example-headers-align">
        <md-expansion-panel hideToggle="true" *ngFor="let u of userRole">
            <md-expansion-panel-header>
                <md-panel-title>
                    {{u.UserName}}
                </md-panel-title>
            </md-expansion-panel-header>
            <div *ngFor="let r of role; let i = index">
                <div>
                    <input type="checkbox" [checked]="(u.RoleIds[i] == r.Id) ? true : false">{{r.Name}}
                </div>
            </div>
            <md-action-row>
                <button md-button color="primary" (click)="saveChanges()">Approve</button>
            </md-action-row>
        </md-expansion-panel>
    </md-accordion>

0 个答案:

没有答案