[英]How can I tell all Angular commands are complete from Javascript?
I am using the following to detect when my page has finished loading, but it is evidently wrong. 我正在使用以下内容来检测我的页面何时完成加载,但这显然是错误的。 The Angular stuff has not been executed yet when document.readyState is complete:
document.readyState完成时,尚未执行Angular的工作:
page.open(url, function (status) {
function checkReadyState() {
setTimeout(function () {
var readyState = page.evaluate(function () {
return document.readyState;
});
if ("complete" === readyState) {
// onPageReady();
doRender();
} else {
checkReadyState();
}
});
}
checkReadyState();
}); });
I didn't get the purpose exactly but you can use $timeout inside angular code which gets executed only after all execution is finished for that particular angular page, and pass a global method which is defined inside your javascript code. 我没有确切地达到目的,但是您可以在角度代码中使用$ timeout,该代码仅在针对特定角度页面的所有执行完成后才执行,并传递在javascript代码内部定义的全局方法。 Something like this-
像这样的东西
Inside JS file - 内部JS文件-
var callBack = function(){
console.log('I have finished execution');
}
Inside Angular Controller - 内角控制器-
$timeout(function(){
callBack();
});
If it doesn't solve your problem please elaborate more. 如果它不能解决您的问题,请详细说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.