0

How can I add more select option in AngularJS example like this:

<div ng-app="MyApp" ng-controller="MyController">
    <label>Student Class:</label>
    <select id="class" name="class">
      <option>C1608G</option>
    </select>
    <a href="#" id="add" style="color: blue;">Add class</a>
</div>

1 Answer 1

1

You can use either attributes/directives:

  • ng-options in your select element
  • ng-repeat in your option element

Here's an example(suppose that you have an array of objects names 'options' in your $scope):

<select id="class" name="class" ng-options="option as option.name for option in options track by option.value">
</select>

<select id="class" name="class">
  <option ng-repeat="option in options">
     <a href="option.address">{{option.name}}</a>
  </option>
</select>
Sign up to request clarification or add additional context in comments.

3 Comments

but how could connect with <a>? And could y write angularJs code pls, i just a newbie so i don't know much about this, sorry @mindthefrequency
in the second provided example, you cann add whatever markup you wish inside the option element.
Thanks a lot!! But how about angularJS code in script

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.