我的编辑表单未使用值属性提交。来自数据库的值已正确绑定

时间:2019-02-13 13:25:46

标签: angular6

   <code> <div class="emplEdit" id="edit">
      <div class="emplEdCont">
        <div class="edtHeeading">
          <h3>Edit Employee Details </h3>
        </div>
        <div class="detlsLink">
          <a href="" id="empDtls" routerLink="/admin/employeeDetails">Employee Details</a>
        </div>
        <div class="editFrm">
          <form [formGroup]="editEmployeeForm" (ngSubmit)="editEmployee()" >
            <p> Note: * Field are mandatory</p>
            <div class="editFrm-left">
              <div class="int">
                <label>User Name*</label>
                <input class="input" type="text" value="{{this.messageResp.result.userName}}" formControlName="userName" [(ngModel)]="this.editEmployeeForm.value.userName" required>
              </div>
              <div class="int">
                <label>Employee Type*</label>
                <select class="input">
                  <option>Admin</option>
                  <option>Employee</option>
                </select>
              </div>
              <div class="int">
                <label>Company/Dept*</label>
                <input class="input" type="text">
              </div>
              <div class="int">
                <label>Mobile Number*</label>
                <input class="input" type="text" value="{{this.messageResp.result.phoneNumber}}" formControlName="mobileNumber" [(ngModel)]="this.editEmployeeForm.value.mobileNumber" required>
              </div>
              <div class="int">
                <label>Country*</label>
                <input class="input" type="text" value="{{this.messageResp.result.country}}" formControlName="country" [(ngModel)]="this.editEmployeeForm.value.country" required>
              </div>
            </div>
            <div class="editFrm-left last">
              <div class="int">
                <label>First Name*</label>
                <input class="input" type="text" value="{{this.messageResp.result.firstName}}" formControlName="firstName" [(ngModel)]="this.editEmployeeForm.value.firstName" required>
              </div>
              <div class="int">
                <label>Last Name*</label>
                <input class="input" type="text" value="{{this.messageResp.result.lastName}}" formControlName="lastName" [(ngModel)]="this.editEmployeeForm.value.lastName" required>
              </div>
              <div class="int">
                <label>Password*</label>
                <input class="input" type="password" value="{{this.messageResp.result.password}}" formControlName="password" [(ngModel)]="this.editEmployeeForm.value.password" required>
              </div>
              <div class="int">
                <label>Confirm Password*</label>
                <input class="input" type="password">
              </div>
              <div class="int">
                <label>Date Of Joining*</label>
                <input class="input" type="date" value="{{this.messageResp.result.doj}}" formControlName="doj" [(ngModel)]="this.editEmployeeForm.value.doj" >
              </div>
              <div class="int">
                <label>Email Id*</label>
                <input class="input" type="text" value="{{this.messageResp.result.email}}" formControlName="emailId" [(ngModel)]="this.editEmployeeForm.value.emailId" required>

              </div>
              <div class="int">
                <label>Employee Status</label>
                <select class="input">
                  <option>Active</option>
                  <option>De active</option>
                </select>
              </div>
            </div>
            <div class="subtn">
              <button type="submit" class="btn-main">Update</button>
            </div>
          </form>
        </div>
      </div>
    </div>

    //我想提交具有所有值和验证的表单,但它给出无效的表单和null值。     //我不希望获得“员工身份”的值,并输入正确的信息。     //这是一个编辑表单,因此首先要完成来自数据库的数据。     //问题是数据没有与值绑定(ngModule)并显示无效格式。 //在创建Employee时,我也这样做,但是没有value属性

0 个答案:

没有答案