Angular:选择框已在表单提交

时间:2015-12-01 10:46:39

标签: javascript angularjs

如果发生错误,表单提交

不清除下拉列表中的选定值

这是角度控制器代码

$scope.registerTutorSubmint = function(form, button) {
        $("#gifLoading").removeClass().addClass('show');
        $scope.registerTutor.registrationTime = new Date();
        $scope.registerTutor.country_id = $scope.registerTutor.country_id.id;
        $scope.registerTutor.countryCode_id = $scope.registerTutor.countryCode_id.id;
        $scope.registerTutor.timeZone = $scope.registerTutor.timeZone.cityTimezone;
          if (!$scope.$$phase)
              $scope.$apply();
        tutorOperations.registerTutor($scope.registerTutor)
            .then(function(response) {
                if(response.data.message=='ER_DUP_ENTRY'){
                      alertService.showAlert("Register Tutor","Duplicate Email Entry");
                }else if(response.data.statuscode == 200){
                    alertService.showAlert("Register Tutor",response.data.message=="success"?"New Tutor Added Successfully":response.data.message)
                    .then(function(response){
                        if(response==='ok'){
                            $scope.registerTutor = {};
                            form.$setPristine();
                            form.$setUntouched();
                            button == 'addOneMore' ? '' : $location.path(Routes.manageTutor.url);
                        }

                    });
                 }
                $("#gifLoading").removeClass().addClass('hide');

            });
    };

当我收到回复时,下拉菜单就会被清除。那么我该怎么做才能确保不清除下拉选择值。

0 个答案:

没有答案