AngularJs路由无链接#标签? [英] AngularJs Routing without hashtag in link?
问题描述
我最近开始学习的Web开发AngularJs和我到目前为止喜欢它。不过,我不那么肯定有井号标签视图之间进行路由时withing的链接。我主要关注的是谷歌将如何缓存网站上的页面和链接是否是双向的,即用户能否只需点击www.sampledomain.com/#/orders/450并直接定向到订购页面。这是一个不错的方法,或者是有没有这个标签的方式来路由看法?
当我删除这个标签时,重新加载页面,并获得404错误。谁能给我到底是怎么回事体面的解释。谢谢
当我删除这个标签时,重新加载页面,并获得404错误
块引用>这是因为在你的服务器端code你可能不处理像www.sampledomain.com/orders/450
的请求您可以有你的服务器端code处理由要么返回一个重定向到一个新的URL(www.sampledomain.com/#/orders/450)或干脆直接返回正确的HTML这一请求。 正确的解决方案将取决于您的需求。
I've recently began learning AngularJs for web development and am loving it so far. However, I'm not so sure about having hashtags withing the link when routing between views. My main concern is how Google will cache the pages on the site and whether the links will work both ways, i.e. whether users can just click www.sampledomain.com/#/orders/450 and be directed straight to the order page. Is this an okay method or is there a way to route views without the hashtag?
When I remove the hashtag, the reload the page and gets 404 error. Can anyone give me a decent explanation of what is going on. Thanks
解决方案When I remove the hashtag, the reload the page and gets 404 error
That's because in your server side code you are probably not handling a request like "www.sampledomain.com/orders/450"
You can have your server-side code handle this request by either returning a redirect to the new URL ("www.sampledomain.com/#/orders/450") or just return the correct HTML directly. The "right" solution will depend on your needs.
这篇关于AngularJs路由无链接#标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!