Skip to content

Instantly share code, notes, and snippets.

@andidev
Last active November 17, 2015 16:16
Show Gist options
  • Save andidev/f65fc09ce62a0a4c4393 to your computer and use it in GitHub Desktop.
Save andidev/f65fc09ce62a0a4c4393 to your computer and use it in GitHub Desktop.
waitFor.js
function waitFor(condition, callback) {
if (window.angular != undefined) {
/* do something*/
callback();
} else {
window.setTimeout(function () {
waitFor(condition, callback)
}, 1000);
}
}
console.log('Waiting for angular');
waitFor(function () {
return window.angular != undefined;
}, function (){
console.log('Angular loaded!')
// do something when angular is loaded
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment