[英]Retrieve angular ng-repeat scope outside ng-repeat
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.我有一个 ng-repeat 选择元素,它由 MySQL 表形成,问题是 - 无法在所选选项的 ng-repeat 之外输出范围参数。
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;基本上,这几乎是我需要的,但它只在 Operator div 字段中显示 value="{{item.name}}"; which is logically understandable.
这在逻辑上是可以理解的。
Thought, that simply making the equivalence of item and rec_name will allow me to do something like认为,简单地使 item 和 rec_name 等效将允许我做类似的事情
<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
.同样,我想要做的是输出当前选定选项的
task.param
,由任务形成,在与ng-repeat div
隔离中。
How do I call other item parameters?如何调用其他项目参数?
Thank you for help.谢谢你的帮助。
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:)干杯:)
You have to manually handle the click event.您必须手动处理点击事件。
Use the following code使用以下代码
HTML 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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.