angular / code.angularjs.org

code.angularjs.org
151 stars 747 forks source link

ng-model-options=“{timezone: 'utc'}” resetting the ng-model value when a bootbox confirm modal is opened #41

Open akshayfin opened 5 years ago

akshayfin commented 5 years ago

I am using ng-model-options="{timezone: 'utc'}" to show my date in UTC format throughout.But on the same screen I have a button which opens a modal of bootbox and when that is opened the ng-model gets cleared.This is strange as there is no mention of the date in that function.Below is the code.Thanks in advance.

  <input ng-model-options="{timezone: 'utc'}"
                                        type="text"  name="creationDate" class="form-control req" uib-datepicker-popup="{{format}}" is-open="popup2.open" datepicker-options="dateOptions1" placeholder="{{vm.user.creationDate | date:'dd/MM/yyyy' : 'UTC'}}"  ng-model="vm.user.creationDate" ng-init="vm.user.creationDate  = vm.user1.creationDate" ng-change="vm.maturity(vm.user.creationDate, 'creationDate')" close-text="Close" alt-input-formats="altInputFormats" readonly="readonly" required />

and the bootbox code:

  bootbox.confirm("Are you sure want to delete Test?", function (result) {
        console.log(vm.user);
        if (result == false) {
        return;
        } else {
        let data = Object.assign({}, vm.user);
        data.exposureId = vm.user1._id;
        data.amount = (data.amount + "").split(',').join('');
        UserService.DeleteTest(data).then(response => {
            console.log(response);
            vm.message = response.message;
            vm.show = true;
            $scope.isChecked = false;
            $timeout(function () {
                $scope.isChecked = true;
            }, 4000);
        });
        }
    });