小编Cla*_*dez的帖子

默认选定值 Ng-Zorro

我正在处理与用户相关的信息(创建、删除和编辑),因为我使用相同的反应式 formGroup。当前的功能之一与编辑用户信息有关,一旦用户单击编辑,就会出现一个模态框,其中包含该特定用户的所有信息,除了与角色相关的值之外,这些值是一个列表。我不知道为什么用户没有选择用户默认带来的值,也就是说选项显示与角色相关的所有选项,但不显示与该特定用户相关的选项;在这种情况下, select ng-fox 用于执行此过程。如果有人可以帮助我理解我的代码中的错误是什么,我将非常感激。多谢。

这是我的代码

<nz-select nzMode="multiple" nzPlaceHolder="Inserted are removed" formControlName="role">
<nz-option *ngFor="let roles of this.userMngmtService.getListRoles()" [nzLabel]="roles.name"
 [nzValue]="roles"></nz-option>
Run Code Online (Sandbox Code Playgroud)

Ts 代码:我发送整个用户信息,并且必须进行搜索以将 roleUser_id 与 role_id 匹配,因为它们“不同”,但这部分工作正常。

editUser(user) {
    this.isVisible = true;
    this.tempRoles = [];
    for (let i = 0; i < user.listUserRoles.length; i++) {
      this.tempRoles.push(user.listUserRoles[i].aptRoleEntity);
    }
    console.log('userToEdit', user);
    console.log('userRName', this.tempRoles);
    // Manage the status (Edit) of the modal
    this.userEditEmailEnable = false;
    this.userEdit = true;
    this.idUserEdit = user.user_id;
    this.editForm.patchValue({
      name: user.name,
      email: user.email,
      password: user.password,
      role: this.tempRoles,
    });
    // <label *ngFor="let role …
Run Code Online (Sandbox Code Playgroud)

select default-value angular ng-zorro-antd

6
推荐指数
1
解决办法
7982
查看次数

标签 统计

angular ×1

default-value ×1

ng-zorro-antd ×1

select ×1