找不到具有未指定名称属性+ Angular 6的控件

时间:2019-05-31 13:34:11

标签: angular

我有要在表中显示的用户列表。表包含一个复选框,其值将是用户的ID。

我有由所有用户组成的userList数组。

能否请您帮我,这样我就可以使用控件数组将控件绑定到id复选框上并显示userList数组中的各个用户详细信息。

谢谢

HTML部分

<ng-template #body_content formArrayName="id">
 <tr *ngFor="let userId of getControls('id'); let i = index">
     <td class="checkTd">
          <label class="check_box_label">
             <input type="hidden" [formControlName]="i" id="{{'UserId_'+i}}" value="{{userList[i].id}}">
             <span class="checkmark"></span>
          </label>                                      
       </td>
       <td>
           <div class="cust_name"><a>{{(userList[i])?.game_name}}</a></div>
      </td>
      <td>
          {{userList[i].name}}
      </td>
      <td>
         <a href="mailto:{{userList[i].email}}">{{userList[i].email}}</a>
      </td>
      <td>
         {{userList[i].mobile}}
      </td>
      <td align="center">
          <a class="{{userList[i].game_name.toUpperCase()}}" rel="facebox">{{userList[i].status}}</a>
      </td>
      <td class="t_cen">
          <a (click)="showPopup('You want to delete this customer? Once deleted it cannot be reversed.')"  class="confirmDelete">
              <img src="./assets/img/cross.png" alt="Delete">
          </a>
      </td>
  </tr> 

组成部分

ngOnInit() {
this.userListForm = new FormGroup({
  "id":new FormArray([]),
});    
this.subscription = this.userService.getUsers().subscribe(
  (data) => {
    //console.log(this.userList);
    this.userList = data;
    let controlArray:[] = [];
    for(let i = 0; i< this.userList.length;i++){
      let control = new FormControl(this.userList[i]);
      (<FormArray>this.userListForm.get("id")).push(control);
    }
  }
)
}

0 个答案:

没有答案