简体   繁体   English

Angular.js:防止在浏览器首次加载时加载视图?

[英]Angular.js: prevent view loading when browser loads for the first time?

How can I prevent route loading when I hit refresh or when I load the page for the first time? 当我单击刷新或第一次加载页面时,如何防止路由加载?

My backend respond with a chunk of HTML when ajax request and the whole page when normal request. 我的后端在ajax请求时以HTML块响应,而在正常请求时以整页响应。 If a normal request was made, I don't want angular to made the same request all over again to retrieve the same page but with a chunk of html instead of the whole page when the page loads. 如果发出了正常的请求,我不希望angular再次再次发出相同的请求来检索相同的页面,但是在页面加载时使用的是html块而不是整个页面。

How can I configure this? 我该如何配置?

May be you can't do that. 可能是您做不到。

If you don't want the page to blink when angular load the whole page again, you can use the resolve attribute in angular-route or angular-ui-router. 如果您不希望页面在再次以角度加载整个页面时闪烁,则可以在angular-route或angular-ui-router中使用resolve属性。

You know, if angular don't load the page again, it can't handle user click or something else. 您知道,如果angular无法再次加载页面,它将无法处理用户点击或其他操作。

I have wrote a blog about this, researching the same problem with you, but in chinese. 我已经写了一个有关此问题的博客,与您一起研究了同样的问题,但使用中文。 In the last, I decide to use resolve . 最后,我决定使用resolve

My blog url is http://isay.me/2014/06/angular-prerender-seo-and-use-resolve-for-page-flicker.html 我的博客网址是http://isay.me/2014/06/angular-prerender-seo-and-use-resolve-for-page-flicker.html

Maybe you can have a look or not :) 也许你可以看看或没有:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM