angular - Two-way data binding doesn't on select field -


i'm having problem 2way data binding in angular2 (beta) app. there no errors in console it's hard guess why following snippet works input text field doesn't work select field, ideas?

the {{model.quantity}} doesn't update on selected item change, {{model.name}} in text field.

<div class="form-group">                     <label>name</label>                     <input type="text" class="form-control"                      [(ngmodel)]="model.name" > {{model.name}}                  </div>                 <div class="form-group">                         <label>quantity</label>                         <select class="form-control" [(ngmodel)]="model.quantity">                           <option value="1">1</option>                           <option value="2">2</option>                           <option value="3">3</option>                         </select> {{model.quantity}}                  </div> 

on other hand, when this:

in ts file:

 logchange(input:any) {     console.log('selected value:',input); } 

in view template:

 <div class="form-group">                             <label>quantity</label>                             <select class="form-control" [(ngmodel)]="amount" #amountfield (change)="logchange(amountfield.value)">                              <option value="1">1</option>                              <option value="2">2</option>                              <option value="3">3</option>                             </select>                             {{amount}}                      </div> 

the console displays values on each change event.

i think works, tested on beta.0

consider plunker:

 <select [(ngmodel)]="name">      <option *ngfor="#n of names" [attr.value]="n">{{n}}</option>   </select> 

https://plnkr.co/edit/mmnwgh?p=info


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -