javascript - While selecting date from datepicker shown $apply already in progress -


when select date datepicker shown $apply in progress, , console shown error

error: [$rootscope:inprog] $apply in progress

and directive used is:

enter code here  focus: function (e) {     scope.$apply(function () {         scope.presentdateopened = true;     }); }, change: function (e) {      scope.$apply(function () {         if (element.val() == "") {             ngmodel.$setvalidity('validdate', true);         }     }); }, blur: function (e) {     if (element.val() != "") {         scope.$apply(function () {             var data = element.val().tostring().split('-');             if (data.length == 3) {                 var month = new date(data[2], data[1], data[0]).getmonth();                 var day = new date(data[2], data[1], data[0]).getdate();                 var year = new date(data[2], data[1], data[0]).getfullyear();                  if (!isnan(month) && !isnan(day) && !isnan(year)) {                     if (angular.isdate(new date(day, month, year))) {                         ngmodel.$setvalidity('validdate', true);                         ngmodel.$setviewvalue(new date(data[2], data[1] - 1, data[0]), 'dd-mmm-yyyy');                         ngmodel.$render();                     }                     else {                         ngmodel.$setvalidity('validdate', false);                     }                 } 

instead of scope.$apply use $timeout. more information can find here https://stackoverflow.com/a/17958847/1324935


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -