0

Question is simple I just want to check whether the hyperlink is loaded fully or not inside the ng-click event.

HTML:

<div ng-click='clicked()'>Click me</div>

JS:

$scope.clicked= function() {
window.location='https://firstlink.com';
//
//when above wesbite page is fully loaded then go to below code and load the next link
//
window.location='https://secondlink.com';
}

NOTE:

I don't want to check whether the view is loaded or not, I want to check whether the URL is completely loaded or not. I've checked many articles and posts regarding this but all I'm getting is that how to check whether your angularjs application is loaded or not. I want to get an approach with which I can check that these URLs are loaded fully or not. Below are some questions I already gone through:

Post render call for AngularJs

Execute AngularJs controller function on page load

Sending event when angularjs finished loading

Angularjs event to call after content is loaded

Tk1993
  • 501
  • 8
  • 21

2 Answers2

0

Use the angular.element to wait till page loaded

$scope.clicked= function() {
 window.location='https://firstlink.com';
 //
 //when above wesbite page is fully loaded then go to below code and load the next link
 //

 angular.element(function () {
    window.location='https://secondlink.com';

 });
}
Sachila Ranawaka
  • 39,756
  • 7
  • 56
  • 80
0

Found a solution by myself:

By using intervals I can make the first page to be loaded first and wait until it is fully loaded. Below is the code for it:

window.location='https://firstlink.com';
var interval = setInterval(function() {     
     if(document.readyState === 'complete') {
window.location='https://secondlink.com';
clearInterval(interval);

    }    
    }, 100); 

To read more about this document.readyState see this link

Tk1993
  • 501
  • 8
  • 21