ng-change get new value and original value

前端 未结 7 876
北荒
北荒 2020-11-28 22:20

I\'m using ng-options to select values from a pulldown. I\'d like to be able to compare the old value to the new value. ng-change works well for grabbing the new value of th

相关标签:
7条回答
  • 2020-11-28 23:03

    You can always do:

    ... ng-model="file.PLIK_STATUS" ng-change="file.PLIK_STATUS = setFileStatus(file.PLIK_ID,file.PLIK_STATUS,'{{file.PLIK_STATUS}}')" ...
    

    and in controller:

    $scope.setFileStatus = function (plik_id, new_status, old_status) {
        var answer = confirm('Czy na pewno zmienić status dla pliku ?');
        if (answer) {
            podasysService.setFileStatus(plik_id, new_status).then(function (result) {
                return new_status;
            });
        }else{
            return old_status;
        }
    };
    
    0 讨论(0)
提交回复
热议问题