本文介绍了ng上的Angular JS Action更改选择下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的表,该表包含三行,每行两个值-日期和状态:
I have a simple table with three rows and two values for each row - date and state:
<tbody>
<tr>
<td>Red</td>
<td class="lastModified">{{item.redDate}}</td>
<td class="status">
<select id ="red" class="form-control" ng-change="update();" ng-model="item.redStatus">
<option value="" disabled="" selected="" class="ng-binding">Please select the value</option>
<option ng-selected="step.value === item.redStatus" ng-repeat="(key, step) in steps">{{ step.title }}</option>
</select>
</td>
</tr>
<tr>Green</tr>
<tr>
....
</tr>
</tbody>
因此,红色,绿色和蓝色的简单日期和状态值。
下拉菜单中的一个-状态,第二个-只是输出日期。
So, simple date and status values for red, green and blue.One in dropdown - status, the second - just output date.
在更改选择值时-我需要用今天的日期来更新日期。
On change the select value - i need to update the date with today's date.
`$scope.item.redDate = new Date();`
是否可以有一个像 ng-change = change();这样的函数?
无法通过ng-change发送ID ...
Is it possible to have one function like ng-change="change();"
Can't send with ng-change the ID...
推荐答案
特别感谢 Samir Das 帮助找到解决方案 ng-change = update(id); :
Special thanks to Samir Das with help to find the solution ng-change="update(id);":
<select id ="red" class="form-control" ng-change="update(id);" ng-model="item.redStatus">
<option value="" disabled="" selected="" class="ng-binding">Please select the value</option>
<option ng-selected="step.value === item.redStatus" ng-repeat="(key, step) in steps">{{ step.title }}</option>
</select>
此处是控制者:
$scope.update = function(id){
id = event.target.id;
$scope.item[id+'Date'] = new Date();
};
这篇关于ng上的Angular JS Action更改选择下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!