JC Borlagdan JC Borlagdan - 1 year ago 75
AngularJS Question

How to dynamically make the option selected if it's equal to something?

I'm not good at jQuery or HTML I want to select the option depending on the value passed from an ajax call. The following is what's inside my html

<label class="item item-input">
<input id="" type="text" required ng-model="Data.CompanyTitle">
<select style="width: 100%">

passes either Partner, System or Council. I want the option to be selected depending on what the value of

Answer Source

You can give the select a model and if the value of the option is equal to your variable it gets auto selected

<select ng-model="selectModel">
    <option value="dummy">dummy</option>

and when you set $scope.selectModel = 'dummy' you can see dummy selected

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download