0

i ust use ng-options in a select element in angular js. and in select select i just wants to add a extra options at the beginning of options.my code ===>

<div class="form-group">
     <select class="form-control select2" ng-options="(o.fullName+' ('+o.email+')') for o in SubTeamUserList track by o.id" name="SelectedUserList" ng-model="SelectedUserList" multiple data-placeholder="Search By User" style="width: 100%;">
            <option value="" disabled>Select A User</option>
      </select>
</div>

enter image description here

that is not working for me ? i dont know why.then i search on net and found some solution like => angularJS - add a Static option with ng-options Add two extra options to a select list with ngOptions on it Angular ng-options - Is there a way to add an option when the model contains a value not present in the options list?

after see above solutions i tried =>

     <div class="form-group">
        <select class="form-control select2" ng-options="" name="SelectedUserList" ng-model="SelectedUserList" multiple data-placeholder="Search By User" style="width: 100%;">
              <option value="" disabled>Select A User</option>
              <option ng-repeat="(o.fullName+' ('+o.email+')') for o in SubTeamUserList track by o.id">{{(o.fullName+' ('+o.email+')')}}</option>
        </select>
    </div>

after doing this this is also showing something like => enter image description here but that is also not working for me i dont know why? can anybody help me ???

3
  • please explain more detailed about not working. Commented Jun 16, 2017 at 10:43
  • I don't see any issue in this code: plnkr.co/edit/4DNPr7sR05S1V4eCbiKr?p=preview Commented Jun 16, 2017 at 10:45
  • I think you are missing syntext in ng repeat of option. its should be like : ng-repeat="o.SubTeamUserId as (o.fullName+' ('+o.email+')') for o in SubTeamUserList track by o.id" Commented Jun 16, 2017 at 10:46

0

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.