0

I am facing very strange issue in Chrome,

In my application i am printing receipt in other window using

Window.open(); Window.print();

However if user ignore opened window and click on print button again then i am getting following error.

line no 9 contains print function from my.js

1. Error: [$rootScope:inprog] $apply already in progress 2. http://errors.angularjs.org/1.2.16/$rootScope/inprog?p0=%24apply 3. at http://localhost:62344/external/angularJS/1.2.16/angular.js:78:12 4. at beginPhase (http://localhost:62344/external/angularJS/1.2.16/angular.js:12720:15) 5. at Scope.$apply (http://localhost:62344/external/angularJS/1.2.16/angular.js:12509:11) 6. at HTMLInputElement.<anonymous> (http://localhost:62344/external/angularJS/1.2.16/angular.js:18626:21) 7. at HTMLInputElement.jQuery.event.dispatch (http://localhost:62344/Scripts/jquery-1.8.2.js:3063:9) 8. at HTMLInputElement.elemData.handle.eventHandle (http://localhost:62344/Scripts/jquery-1.8.2.js:2681:46) 9. at Scope.$scope.print (http://localhost:62344/Scripts/app/my.js:5044:34) 10. at http://localhost:62344/external/angularJS/1.2.16/angular.js:10567:21 11. at http://localhost:62344/external/angularJS/1.2.16/angular.js:18627:17 12. at Scope.$eval (http://localhost:62344/external/angularJS/1.2.16/angular.js:12412:28)

On other browsers its working fine.

Any inputs ??

-Thanks, Yogesh

user3249448
  • 1,369
  • 2
  • 14
  • 34
  • 1
    Without having a look at the code or anything...if you wrap the code in your print button function with the following code it might prevent the error. `if ($scope.$root.$$phase != '$apply' && $scope.$root.$$phase != '$digest') { //Your code }` – user1135469 May 23 '14 at 11:51
  • you are calling an apply somewhere in the stack that is causing this issue. It is likely that it is being called to low in the stack, and as @user1135469 suggest you might need to call the apply method safely. There are several ways to accomplish this. Showing us some more code would help. – Jared Reeves May 23 '14 at 12:03
  • I have tried this but still have issue.. if ($scope.$root.$$phase != '$apply' && $scope.$root.$$phase != '$digest'). In this solution i have found that $scope.$root.$$phase always remains "$apply". – user3249448 May 23 '14 at 13:30

1 Answers1

0

Problem is with chrome. we have solved this issue using following solutions

Print a div using javascript in angularJS single page application

Javascript window.print() in chrome, closing new window or tab instead of cancelling print leaves javascript blocked in parent window

Community
  • 1
  • 1
user3249448
  • 1,369
  • 2
  • 14
  • 34