验证 ngx-admin angular 项目中的表单布局

Validation of form layouts in ngx-admin angular project

借助 ngx-admin/forms/form 布局形式。我做了我自己的表格。现在我想对表单应用验证并将数据发送到 firebase。我尝试使用 formgroup,ngmodel。什么都不管用。帮帮我。

这是表单布局的 link - 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>

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