我有以下ui-select
html:
<ui-select ng-model="actionSelectedId"
on-select="changedAction($item, $select, row)"
theme="bootstrap"
ng-disabled="disabled">
<ui-select-match placeholder="Select an action">
<span>{{$select.selected.name || $select.search}}</span>
</ui-select-match>
<ui-select-choices repeat="action.id as action in actions | filter: $select.search">
<span ng-bind-html="action.name | highlight: $select.search"></span>
</ui-select-choices>
</ui-select>
我想在控制器的changedAction
方法中检索以前选择的操作ID
e.g。来自html的方法调用如下所示将给出之前选择的值,因此需要知道如何获得oldSelection
:
on-select="changedAction($item, $select, row, oldSelection)"
答案 0 :(得分:1)
$scope.$watch('actionSelectedId', function(newValue, oldValue) {
$scope.oldValue = oldValue;
$scope.newValue = newValue;
});