Last active
November 17, 2015 16:16
-
-
Save andidev/f65fc09ce62a0a4c4393 to your computer and use it in GitHub Desktop.
waitFor.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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