select tag value results undefined ..... formControlName [ionic,Angular2]

时间:2017-01-18 12:44:02

标签: forms angular select ionic-framework

我正在尝试使用formcontrolName从表单中获取数据。所以我使用选择标签,我无法检索所选的选项。获取其他字段的值。 这是组件

constructor(public navCtrl: NavController,public formBuilder: FormBuilder, public params :NavParams) { 
  this.loan = params.get('loan');

this.amountForm = formBuilder.group({
    payment: ['']
  });

  this.paymentForm = formBuilder.group({
    paymentmode: [''],
    chequenumber: [''],
    chequedate: [''],
    payername: [''],
    mobile: ['']
  });
}

getPaymentDetails(): void {
  //will need a separate api
  console.log(this.amountForm.value)
  console.log(this.paymentForm.value["paymentmode"])`}`

这是html:

     <form [formGroup]="paymentForm">

  <ion-row>
    <ion-col>Payment Mode</ion-col>
    <ion-col>
      <!--<input type="text" formControlName="paymentmode" />-->
      <!--<h3> hello </h3>-->
      <select class="form-control" formControlname="paymentmode" >
                  <option value="null">Select payment method</option>
                  <option value="CASH">CASH</option>
                  <option value="CHEQUE" selected>CHEQUE</option>
                </select>
    </ion-col>
  </ion-row>
<div>
  <ion-row>
    <ion-col>Cheque Number</ion-col>
    <ion-col>
      <input type="text" placeholder="FILL ONLY IF CHEQUE" formControlName="chequenumber" />      
    </ion-col>
  </ion-row>

  <ion-row>
    <ion-col>Cheque Date</ion-col>
    <ion-col>
      <input type="text" placeholder="FILL ONLY IF CHEQUE" formControlName="chequedate" />      
    </ion-col>
  </ion-row>
</div>
<ion-row>
    <ion-col>payer name</ion-col>
    <ion-col>
      <input type="text" formControlName="payername" />      
    </ion-col>
  </ion-row>
  <ion-row>
    <ion-col>Phone Number</ion-col>
    <ion-col>
      <input type="text" formControlName="mobile" />      
    </ion-col>
  </ion-row>
  </form>

paymentmode导致对象{paymentmode:“”}

0 个答案:

没有答案