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();`
Is it possible to have one function like ng-change="change();"
Can't send with ng-change the ID...
是否有可能有一个函数,如ng-change =“change();”无法使用ng发送更改ID ...
1 个解决方案
#1
13
Special thanks to Samir Das with help to find the solution ng-change="update(id);":
特别感谢Samir Das帮助找到解决方案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>
Here is the controller:
这是控制器:
$scope.update = function(id){
id = event.target.id;
$scope.item[id+'Date'] = new Date();
};
#1
13
Special thanks to Samir Das with help to find the solution ng-change="update(id);":
特别感谢Samir Das帮助找到解决方案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>
Here is the controller:
这是控制器:
$scope.update = function(id){
id = event.target.id;
$scope.item[id+'Date'] = new Date();
};