javascript - angularJS - ng-if and ng-model -


i trying display field based on value of select in angular app. should simple: when newjob.country === 'remote' want 'city' field disappear:

html:

  <body ng-app>         <div class="form-aside">           <label>location</label>           <select ng-model="newjob.country" class="form-control">             <option>remote</option>             <option>france</option>             <option>uk</option>           </select>         </div>         <div class="form-aside" ng-if="newjob.country !== 'remote'">           <label>city</label>         </div>   </body> 

for reason it's not working. here plunker: http://plnkr.co/edit/gcjneps9zvkejniattiw?p=preview

how can make work?

thanks

you need define valuefor each <option> tag.

then need use ng-show != dynamically display label or not.

your plunker should work this:

<body ng-app>     <div class="form-aside">       <label>location</label>       <select ng-model="newjob.country" class="form-control">         <option value="remote">remote</option>         <option value="france">france</option>         <option value="uk">uk</option>       </select>     </div>     <div class="form-aside" ng-show="newjob.country != 'remote'">       <label>city</label>     </div> </body> 

plunker here : http://plnkr.co/edit/meqpbovxrh4antqlxdoy?p=preview


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -