I have this anchor tag and i change my view depending on the date coming from the object. I am trying to change it to be a select option but it is not working the way i am doing it.
This is anchor tag syntax:
<a href="#" ng-repeat="item in home.prData" ng-click="home.selectedPr = item; $event.preventDefault();
$event.stopPropagation();">{{item.date}}</a>
I am trying to change it to be like that when i use select option
<select st-search="{{item.date}}" class="show-tick form-control dropdown_custom_list">
<option value="">- select a date -</option>
<option ng-repeat="item in home.prData" value="{{home.selectedPr = item}}">{{item.date}}
</option>
</select>
i created an example plunkr to what i am trying to achieve:
after i kept trying and searching i found a solution so i had to use an ng-model and assign it to my selectedPr as my example. and it worked
Try adding a
ng-model
variable and onng-change
assign selected date.ng-change
wont work withoutng-model
See AngularJS select Directive API Reference - Using
ngRepeat
to generateselect
optionsUpdate
Be sure to use the ng-model directive.
For values that are other than strings, use the ng-value directive:
For more information,
ngValue
to bind the model to an array of objectsngRepeat
to generateselect
optionsselect
withngOptions
and setting a default value