如何将[键:字符串]值更改为下拉列表中的数字?

时间:2019-04-03 06:07:57

标签: html angular typescript

HTML代码

    <mat-form-field>
      <select formControlName="Type" >
        <option value=0 >Related To The Team</option>
        <option value=1 >Personal</option>
        <option value=2 >Recommended By The Evaluator</option>
      </select>
    </mat-form-field>
    <mat-form-field>
      <select matNativeControl required formControlName="Attribute">  
        <option value=0 >Specific</option>
        <option value=1 >Measurable</option>
        <option value=2 >Attainable</option>
        <option value=3 >Relevant</option>
        <option value=4 >TimeBound</option>
      </select> 
    </mat-form-field>

.TS代码

我尝试使用null和数字

      ngOnInit() {
      this.Form = this.formBuilder.group({
      Type: [null],
      Attribute: Number['']});

我的虚空

     onSubmit(): void{
     this.Service.add(this.Form.value)
     .pipe(first())
     .subscribe();
     console.log('test', this.Form.value);
     }

但它仍返回值:

    test Object { Type: "0", Attribute: "2"}

作为字符串

我应该如何转换?

0 个答案:

没有答案