从浏览器中断直接访问 angular2 路由
Directly accessing angular2 routes from browser breaks
在 angular2 之前,如果我们想直接从浏览器到达 angularJS 中的路由,假设是 signup
路由,我们使用像这样的 hashbang 方法 (#/
) - www.example.com/#/signup
但是对于 angular2 这个剂量起作用了。
我只能直接点击索引路由上的注册按钮访问注册路由 - www.example.com/
我已经 <base href="/">
添加了。
请问我如何直接从浏览器访问注册路径 url 吧。谢谢。
有效。您必须在应用程序中定义您的位置策略。
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy } from "angular2/router";
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
...
bind(LocationStrategy).toClass(HashLocationStrategy)
]);
因此,如果您想使用带有 # 的 url,您的策略是 HashLocationStrategy
在 angular2 之前,如果我们想直接从浏览器到达 angularJS 中的路由,假设是 signup
路由,我们使用像这样的 hashbang 方法 (#/
) - www.example.com/#/signup
但是对于 angular2 这个剂量起作用了。
我只能直接点击索引路由上的注册按钮访问注册路由 - www.example.com/
我已经 <base href="/">
添加了。
请问我如何直接从浏览器访问注册路径 url 吧。谢谢。
有效。您必须在应用程序中定义您的位置策略。
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy } from "angular2/router";
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
...
bind(LocationStrategy).toClass(HashLocationStrategy)
]);
因此,如果您想使用带有 # 的 url,您的策略是 HashLocationStrategy