Search code examples
angularjsangular-bootstrap

Angular bootstrap select field


I am trying to create an angular bootstrap select field from inside a directive. The directive creates the following dom structure but the select field is empty.

<select class="form-control" ng-options="f for f in ["i","j","k"]"><option></option></select>

What is the correct way to create the select field in this case.


Solution

    1. Use single quotes in side double quotes
    2. ng-model is required.

    Here is the code

    <select ng-model="myChoice" class="form-control" ng-options="f for f in ['i','j','k']"></select>