Angular Tips: ng-options does not work

Published on 2017-11-22 by Raul

When binding a select with ng-options, even though I had data in the array, the select wasn't populated.

The code I used was standard, from angular point of view:

<select 
    ng-options="choice.ID as choice.Name for choice in Choice.Options">
</select>

 The problem was that I did not bound the model to the select. So after changing the code to add a model, it worked fine:

<select 
    ng-model="Choice.Selection"
    ng-options="choice.ID as choice.Name for choice in Choice.Options">
</select>

 


Keep in touch


About

Hey there, I'm Raul, owner of CreativeCLR, a small consulting company.

Feel free to drop me any question you might have on this post using the comment section or the contact page.