It’s fun solving

Solving errors is so much fun… You get to learn new concepts and understand how to code efficiently. These are 2 things I learnt today.

  • $timeout rescues. I was trying to open a PDF file using window.open(…). During app testing, the following error popped out.

Code        : window.open(‘url’, ‘_blank’, ‘location=yes, closebuttoncaption=done’) ;

Error       : [$rootScope:inprog] $digest already in progress

Solution : 

$timeout(function(){
    window.open(‘url’, ‘_blank’, ‘location=yes, closebuttoncaption=done’) ;
});

Reason   : There is a $digest cycle which is already running. The new event must be triggered once this cycle is completed. In such a case, $timeout acts as a savior. Wrap the code in the $timeout(function(){…}); and your free from that error 

Resource : https://docs.angularjs.org/api/ng/type/$rootScope.Scope#$digest

  • The Ionic View Problem. window.open() has a attribute which can be used to close the new opened window.

Code       : window.open(‘url’, ‘_blank’, ‘location=yes, closebuttoncaption=done, toolbarposition=top’);

Details   : _blank is used to open URL in a new window. closebuttoncaption=done is used to display a button labelled ‘done‘ which closes the new window when clicked. This button is positioned on top using toolbarposition=top

Problem : When trying to test this app on Ionic View, the toolbar and the closebuttoncaption are not visible. However, it works good on iPhone, Android as well as Browser. So… Don’t waste your time trying to fix your code or thinking about it’s visibility when you are testing it using Ionic View.

Interesting Issues. Isn’t it…??!!!

Previous
Previous

The ng- thing

Next
Next

The Iconic View