以前为ui选择更改的选项

时间:2016-04-20 19:49:12

标签: javascript angularjs

我有以下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)"

如果ui-select

可以,请告知我们

1 个答案:

答案 0 :(得分:1)

$scope.$watch('actionSelectedId', function(newValue, oldValue) {
    $scope.oldValue = oldValue;
    $scope.newValue = newValue;
});