0

借助 ngx-admin/forms/form 布局的表单。我制作了自己的表格。现在我想对表单应用验证并将数据发送到 firebase。我尝试使用formgroup,ngmodel。没有任何效果。帮帮我。

这是 formlayout 的链接 - https://www.akveo.com/ngx-admin/pages/forms/layouts

我从这里下载了模板 - https://akveo.github.io/ngx-admin/

<nb-card>
  <nb-card-header>Appointment form</nb-card-header>
  <nb-card-body>

    <form class="form-horizontal">

      <div class="row">

        <div class="col-lg-6">
        <div class="form-control-group">
          <label for="title" class="label col-sm-3 form-control-label">Title</label>
            <div class="col-sm-9">
            <nb-select selected="1" id="title">
              <nb-option value="1">Select</nb-option>
              <nb-option value="2">Mr.</nb-option>
              <nb-option value="3">Mrs.</nb-option>
              <nb-option value="4">Ms</nb-option>
            </nb-select>
          </div>
        </div>

        <div class="form-group row">
          <label for="fname" class="label col-sm-3 form-control-label">First Name</label>
          <div class="col-sm-9">
            <input 
              type="text" nbInput fullWidth id="fname" placeholder="First Name" 
              required/>
          </div>
        </div>

        <div class="form-group row">
          <label for="mname" class="label col-sm-3 form-control-label">Middle Name</label>
          <div class="col-sm-9">
            <input type="text" nbInput fullWidth id="mname" placeholder="Middle Name">
          </div>
        </div>

        <div class="form-group row">
          <label for="lname" class="label col-sm-3 form-control-label">Last Name</label>
          <div class="col-sm-9">
            <input type="text" nbInput fullWidth id="lname" placeholder="Last Name">
          </div>
        </div>
    </div>

      <div class="col-lg-6">
        <div class="form-group row">
          <label for="email" class="label col-sm-3 form-control-label">Email</label>
          <div class="col-sm-9">
            <input type="email" nbInput fullWidth id="lname" placeholder="Email">
          </div>
        </div>

        <div class="form-group row">
          <label for="adrss" class="label col-sm-3 form-control-label">Address</label>
          <div class="col-sm-9">
            <textarea rows="5" id="adrss" nbInput fullWidth shape="round"  placeholder="Address"></textarea>
          </div>
        </div>

        <div class="form-group row">
          <label for="doctor" class="label col-sm-3 form-control-label">Referred By</label>
            <div class="col-sm-9">
            <nb-select selected="1" id="doctor">
              <nb-option value="1">Select</nb-option>
              <nb-option value="2">Dr. Abc</nb-option>
              <nb-option value="3">Dr. Xyz</nb-option>
              <nb-option value="4">Dr. Lmn</nb-option>
            </nb-select>
          </div>
        </div>

      </div>

        <div class="form-group row">
          <div class="offset-sm-3 col-sm-9">
            <button type="submit" nbButton status="warning">Book Appointment</button>
        </div>
      </div>


    </div>
    </form>
  </nb-card-body>
</nb-card>

4

1 回答 1

3

这是如何使用反应式表单的示例:首先,您必须从模块中的 angular/forms 导入ReactiveFormsModule,然后您可以使用formGroup指令和FormControlName指令提供的formControlName输入来绑定每个输入。检查: https ://angular.io/guide/reactive-forms

于 2020-03-11T09:58:33.477 回答