1

In Angularjs, binding input select to the model creates new empty option

<option value="? undefined:undefined ?"></option>

And this is the code

<select name="category" ng-model="hotspot.category">
  <option>Culture</option>
  <option>Education</option>
  <option>Parks</option>
  <option>Student Pubs</option>
</select>

Is this normal? It doesn't seem to be something good looking.

1 Answer 1

1

Make sure you have initialized your model variable with one of the option value.

Try this

Controller

$scope.hotspot = {};
$scope.hotspot.category = "Culture";

HTML

<select name="category" ng-model="hotspot.category">
  <option>Culture</option>
  <option>Education</option>
  <option>Parks</option>
  <option>Student Pubs</option>
</select>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.