Angular 2 - Undefined when try to get the value from select

Viewed 13062

I'm new on Angular 2 and i have this problem. I have a select with 3 options and i cannot get the value of one of this options.

The html:

<select [(ngModel)]="product_type" class="form-control" (ngModelChange)="getType()">           
        <option [ngValue]="A"><span>ALL</span></option> 
        <option [ngValue]="T"><span>Type product</span></option>
        <option [ngValue]="E"><span>Standart product</span></option>            
    </select>

Component.ts:

 type_product:string;
/*...*/
 getType(){
   this.type_product= ""+this.type_product;
  console.log(this.type_product);

}

When i execute it, the log shows undefined. What i'm doing wrong? Thank you

4 Answers
Related