我正在尝试在table元素中添加formControl,但我总是得到
error:No value accessor for form control with name: 'sender'
。我尝试使用formControl或formControlName,但没有成功。我说几个aritcles,它说使用formControl没有标签,但它没有成功
有我的代码:
<form [formGroup]="toolsubmitform">
<div class="row">
<div class="col-xl-4 col-lg-5">
<md-card class="user-card">
<!-- <md-card-header>
<img class="rounded-circle img-user" width="70" height="70" src="assets/img/SB-admin.png">
</md-card-header> -->
<md-card-title class="user-title">Stuff</md-card-title>
<md-card-content>
<img class="rounded-circle img-user" width="100" height="100" src="assets/img/SB-admin.png">
<table class="table table-bordered">
<thead class="table-head">
<tr>
<th>staff Name</th>
</tr>
</thead>
<tbody>
<tr >
<td><span formControlName='sender'>Jason</span></td>
<td></td>
</tr>
</tbody>
</table>
</md-card-content>
</md-card>
</div>
</form>
这是我的组件:
import { Component, OnInit,HostListener,NgModule } from '@angular/core';
import {FormGroup, FormControl, Validators,FormArray,FormBuilder} from '@angular/forms';
import {HomepageService} from './homepage.services';
import {ToolUsing, Tool,Tooldetail} from './homepage.interface';
this.toolsubmitform=new FormGroup({
'sender':new FormControl(),
'operator':new FormControl(),
tool:new FormArray([
// this.initTool(),
]),
})
这是我的angular2版本:
"@angular/common": "^2.3.1",
"@angular/compiler": "^2.3.1",
"@angular/core": "^2.3.1",
"@angular/forms": "^2.3.1",
"@angular/http": "^2.3.1",
"@angular/material": "^2.0.0-beta.1",
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/router": "^3.3.1",