Reputation: 23
I have a ng-repeat select element, which is formed from the MySQL table, problem is - can't output scope parameter outside of the ng-repeat of the selected option.
What I tried doing:
<select ng-model="rec_name">
<option value=" ">Select</option>
<option ng-selected="{{rec_name == item}}" ng-repeat="item in tasks" value="{{item.name}}">{{item.name}}</option>
</select>
<div>Operator is: {{rec_name}}</div>
Basically, it's almost what I need, but it only shows the value="{{item.name}}" in the Operator div field; which is logically understandable.
Thought, that simply making the equivalence of item and rec_name will allow me to do something like
<div>Operator is: {{rec_name.param}}</div>
Again, what am I trying to do is to output the task.param
of currently selected option,formed from tasks, in the isolated from ng-repeat div
.
How do I call other item parameters?
Thank you for help.
Upvotes: 2
Views: 363
Reputation: 41571
You have to manually handle the click event.
Use the following code
HTML
<select class="form-control" ng-model="selecteditem"
ng-options="selecteditem as selecteditem.brand for selecteditem in dropdownval">
</select>
<div>Operator is: {{clicked_rec_name}}</div>
Have the following method in your controller
$scope.getClickedItem=function(item)
{
$scope.clicked_rec_name=item.rec_name;
}
Upvotes: 0
Reputation: 3384
you can do like this:
<select ng-model="rec_name">
<option value=" ">Select</option>
<option ng-selected="{{rec_name == item}}" ng-repeat="item in tasks" value="{{item.name}}">
<a href="#" ng-click="rec_name == item">
{{item.name}}
</a>
</option>
</select>
<div>Operator is: {{rec_name}}</div>
Cheers:)
Upvotes: 1