简体   繁体   English

处理页面刷新/ F5 angular js和laravel

[英]Handle page refresh/f5 angular js and laravel

I am building an application with angular js( new to angular js ) and laravel. 我正在使用angular js(角度js新手)和laravel构建应用程序。 All laravel routes except home page route serves only json data needed for that page. 除首页路由外,所有laravel路由仅提供该页面所需的json数据。 Home page loads all the necessary stuff that angular js has to work with. 主页加载了angular js必须处理的所有必要内容。 The problem is that if user decides to refresh the page when he/she is on a url other than home page, the page displays only json data, since there is no css,script and html loaded. 问题在于,如果用户决定在其主页以外的其他URL上刷新页面,则该页面仅显示json数据,因为没有加载css,script和html。 My question is what is the best and professional way of handling page refresh/f5 with angular? 我的问题是用angular处理页面刷新/ f5的最佳和专业方法是什么? Should i prevent the page refresh at all, if yes how? 我应该完全阻止页面刷新吗,如果可以,怎么办? Hope my question is clear enough... 希望我的问题很清楚...

According to your post and comment here are 3 proposed solutions/suggestion. 根据您的帖子和评论,这里有3个建议的解决方案/建议。

  1. Stay on one url and manage the json only,dont change your url it direct to your laravel route request if refreshed by user. 停留在一个网址上,仅管理json,如果用户刷新,则不要直接将其更改为laravel路由请求的网址。

  2. Using angularjs default hashtag(#) method is better, to understand angular and laravel. 使用angularjs默认的hashtag(#)方法更好,以了解angular和laravel。

  3. Send a variable with your angularjs request to route to identify that it comes from angular and check in your route. 发送带有您的angularjs请求的变量以进行路由,以识别该变量来自angular并签入您的路由。 If from angular return json otherwise you can redirect to home page. 如果从angular返回json,则可以重定向到主页。

I hope it will help 希望对您有所帮助

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

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