Angular应用仅在页面刷新时加载 [英] Angular app only loads on page refresh

查看:40
本文介绍了Angular应用仅在页面刷新时加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用一个有角度的应用程序页面构建一个wordpress网站.它一直工作到最近(并且我不记得是哪个更改使它失败了),但是现在当我通过链接到达页面时,该应用程序无法加载(已加载角度并且下面的代码段已处理,但未记录任何内容),但可以正常工作,如果我随后刷新页面的话.

I am building a wordpress site with a page that is an angular app. It was working until recently (and I can't recall which change broke it), but now the app does not load when I arrive at the page via a link (angular is loaded and the code snippet below processed, but nothing is logged), but it does work if I then refresh the page.

我已退出所有实际代码:

I've backed out all the real code to leave:

angular.module("af2015App", [])
.controller("TestCtrl", function() {
    console.log("test test");
});

并注释掉HTML中的所有内容,除了

And commented out everything in the HTML except

<div ng-app="af2015App" class="app">
    <p ng-controller="TestCtrl">Use the ...!</p>
</div>

我不知道如何调试这些情况.我通过AJAX加载页面.

I'm at a loss as to how to debug these circumstances. I'm not loading pages via AJAX.

推荐答案

谢谢大家的想法.我又去调试了一次,发现即使关闭了angular的脚本标签后,仍然存在angular.那使我有了看待Batarang的想法,并且在停用该功能之后,所有功能都再次起作用.也许这一答案有一天会有所帮助.不用说,我不知道潜在的问题是什么.

Thanks for your ideas everyone. I had another go at debugging and discovered that, even after turning off the script tag with angular, angular was still present. That gave me the idea to look at Batarang and, after deactivating that, all is working again. Perhaps this answer will help someone someday. Needless to say I don't know what the underlying problem was.

这篇关于Angular应用仅在页面刷新时加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆