简体   繁体   English

我怎样才能知道所有Angular命令是从Javascript完成的?

[英]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.

相关问题 我怎么能告诉这个HTML代码中的javascript不影响所有按钮? - How can i tell the javascript in this html code not to influence all the buttons? 如何判断ReactJS是否处于JavaScript开发模式? - How can I tell whether ReactJS is in development mode from JavaScript? 如何判断 iPhone 是否从 javascript 后台返回? - How can I tell if iPhone is returning from background in javascript? 如何判断Javascript对象是否为文件? - How can I tell if a Javascript object is a File? 如何获得emacs来区别编写PHP,HTML和JavaScript时的区别? - How can I get emacs to tell the difference from when I am writing PHP, HTML, and JavaScript? Javascript可以告诉JavaFX生成线程并在完成时得到通知吗? - Can Javascript tell JavaFX to spawn a thread and be notified when complete? 如何在JavaScript中以编程方式判断从哪个文件中将特定CSS类应用于HTML元素? - How can I programmatically tell, in JavaScript, from which file a particular CSS class is getting applied to an HTML element? 如何判断对象是否是Angular $ q承诺? - How can I tell if an object is an Angular $q promise? 我怎么知道 <textarea> 在Angular 8应用程序中为空? - How can I tell if a <textarea> is empty in an Angular 8 application? 我可以告诉 Javascript 从另一个 JS 文件调用方法吗? - Can I tell Javascript to call a method from another JS file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM