when selecting value dropdown list "practice list" , clicking on save button, , again modifying item can see dropdown list not holding selected value i.e., "practice list". instead holding default value i.e., "my list". how can make hold selected value after saving data?
here's html code:
<select id="{{::prefix}}_select_practice" name="freetextdrugschedule" ng-options="option option.name option in data.practiceoptions" class="form-control medium" ng-model="data.savein" style="margin-bottom: 5px;"> <option value="" selected="selected">my list</option> </select> <button id="{{::prefix}}_button_submit" class="btn btn-primary" ng-click="validations = null; dosubmit()">{{submitverb}}</button>
here's js file code:
$scope.dosubmit = function (datatosubmit) { $scope.submitted = true; if (datatosubmit) { if ($scope.data.savein) { datatosubmit.datatosubmit.savein = $scope.data.savein; } $scope.data = datatosubmit.datatosubmit ? datatosubmit.datatosubmit : datatosubmit; } validatesubmission(); // todo simplify validation if ($scope.enterdetailsform.$invalid || $scope.showeffectivedateerror || $scope.showeffectivedaterangeerror || ($scope.sigvalidations && $scope.sigvalidations.length) || ($scope.data.pharmacy1 && $scope.data.pharmacy1 == $scope.data.pharmacy2) || ($scope.showmdd && (!$scope.data.medication.maximumdailydose || ($scope.showmdd == 'pd' && !$scope.data.medication.maximumdailydoseunit))) || $scope.showprovidererror || $scope.showsupervisorerror || $scope.drugminerror || $scope.showprimaryerror) { $scope.validations.push({ name: 'invalid entry', msg: 'please correct errors on form continue.' }); if ($scope.entity == 'prescription') { $scope.scrolltoerror = true; } } else if ($scope.entity == 'prescription' && !validateduration()) { $scope.$emit('ghostmessage', 'the length of prescription should not more 365 days'); } else { //proceed submission // prepare data submitted alert checker var datatosubmit = preparedatatosubmit(); // validate payload before submit if (datatosubmit.medication.lastrefilldate && datatosubmit.medication.startdate && datatosubmit.medication.lastrefilldate.date < datatosubmit.medication.startdate.date) { $scope.$emit('ghostmessage', 'last written date cannot before start date.'); } else if (datatosubmit.medication.lastrefilldate && datatosubmit.medication.stopdate && datatosubmit.medication.lastrefilldate.date > datatosubmit.medication.stopdate.date) { $scope.$emit('ghostmessage', 'last written date cannot after stop date.'); } else if (datatosubmit.medication.diagnoses && datatosubmit.medication.diagnoses.length == 2 && datatosubmit.medication.diagnoses[0].code && datatosubmit.medication.diagnoses[0].code == datatosubmit.medication.diagnoses[1].code) { $scope.$emit('ghostmessage', 'you may not specify same diagnosis code both primary , secondary diagnoses'); } else if ($scope.entity != 'favoriterx' && $scope.showdawgenericwarning && !$scope.formularycheckedfordawwarning) { checkformularyalertsfordawwarning(datatosubmit); } else { $scope.formularycheckedfordawwarning = false; // check dose alerts if necessary datatosubmit.schedules = angular.copy(schedules); if ($scope.entity == 'prescription' && dosecheckneeded) { checkdosealerts(datatosubmit); } else { // done; process submission $scope.submit({data: datatosubmit, optioncodes: $scope.optioncodes}); $scope.loading = 0; } } } };
i'm not sure asking for, or mean "saving" data, try offer assistance.
i don't know angular.js, suggestion wrap select in form (which assume you're doing) , set value using post value in angluar.js (if can that). way, if reload page, not load default value. additionally, if you're merely inspecting element in browser after select new option, won't show new option selected (i.e. selected="" attribute still on default).
Comments
Post a Comment