表格不适用于angular2

时间:2016-10-28 13:53:34

标签: angular typescript

最近我正在处理表单但是当我运行我的代码时,我收到以下错误

componentWillUnmount

我的组件,

this.mounted

我的模板,

 No provider for ControlContainer ("
        </div>
        <div class="modal-body">
          [ERROR ->]<form [formGroup]="form" (ngSubmit)="onSubmit(form.value)">
            <div class="form-group">
  "): TablesBasic@112:10
No provider for NgControl ("       <div class="form-group">
              <label for="email">FirstName:</label>

之前我曾经多次使用过这种形式,但我没有遇到过这种错误,有人可以建议帮忙。谢谢。

我的ngModule,

import { Component,ViewChildren,OnInit } from '@angular/core';
import { Ng2TableModule } from 'ng2-table';
import { Http, Headers } from '@angular/http';
import { FormGroup, FormControl, FormBuilder, Validators } from '@angular/forms';
import { emailValidator } from './validator'
declare var Messenger: any;
@Component({
  selector: '[tables-basic]',
 templateUrl: './tables-basic.template.html'
})
export class TablesBasic implements OnInit {
  form:FormGroup;
  students:any;
  emailerror:any;
  firstnameerror:any;
  phoneerror:any;
  constructor(public http: Http,public fbld: FormBuilder) {
this.form = fbld.group({
            accountname: ['', Validators.required],
            lastname: ['', Validators.required],
            email: ['', emailValidator],
            phone: ['',  Validators.required]
})

    }

0 个答案:

没有答案