Angular dart 书签视图 [英] Angular dart bookmarking views

查看:19
本文介绍了Angular dart 书签视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的经验,Angular Dart 与您的后端服务器实现无关.它不在乎你的服务器是在 java、ruby 还是其他的.Angular dart 有视图的概念,并且有一个处理视图之间路由的模块.当浏览器改变视图时,这些路由也会修改浏览器的地址栏.

It is my experience that Angular Dart is agnostic to your backend server implementation. it doesn't care if your server is in java, ruby or whatever. Angular dart has the concept of views and has a module that deals with routing between them. these routes also modify the address bar of the browser when it changes views.

我遇到过这个问题.虽然角度路由模块会改变地址栏,因为就后端服务器而言,所述路由实际上并不存在,因此总是会发出 404 响应.

I have come across this issue. Though the angular router module will change the address bar, because said route doesn't actually exist as far as the backend server is concerned, and as such will always issue a 404 response.

如果是这种情况,那么我发现通过 angular 路由到不同页面的能力毫无意义.我还不如以更传统的面向服务器的方式编码以在页面之间转换,而不是起诉 angular.

If such is the case, then I find the ability to route to different pages via angular to be pointless. Might as well I code in a more traditional server oriented fashion to transition between pages, than to sue angular.

是不是少了点什么?有没有办法让您的服务器解析到正确的角度页面?

Is it that there is something that is missing? Is there a way you can can get your server to resolve to the correct angular page?

推荐答案

您可以使用 usePushState: false 然后只更改 URL 的(客户端)本地部分.
https://github.com/angular/angular.dart.tutorial/blob/master/Chapter_06/web/main.dart#L27
哈希之后的这部分永远不会发送到服务器.
这可能会给 SEO 带来一些额外的工作.

You can use usePushState: false then only the (client) local part of the URL is changed.
see https://github.com/angular/angular.dart.tutorial/blob/master/Chapter_06/web/main.dart#L27
This part after the hash is never sent to the server.
This might cause some additional work for SEO.

http://example.com/index.html#someRoutePath/anotherRoutePath

或者您可以配置您的服务器,使每个请求的处理独立于请求中的路径,并且也使用路由包服务器端.

or you can configure your server in a way that each request is handled independent of the path in the request and use the route package server side too.

另见https://stackoverflow.com/a/17909743/217408

这篇关于Angular dart 书签视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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