如何通过在angular2打字稿改变路由器 [英] how to change router by typescript in angular2

查看:225
本文介绍了如何通过在angular2打字稿改变路由器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关〔实施例我用的路由器链路是这样的:

for exmaple I use router-link like this:

<li><a [router-link]="['/start']">Start</a></li>

但我怎么能更改路由器/由打字稿启动?

but how can I change the router to /start by typescript?

推荐答案

小更新哈希定位策略有关。

Small update related to hash location strategy.

在最近的版本中angular2的绑定的方法是去precated这样你就可以使用提供方法。

In recent versions of angular2 the bind method is deprecated so you can change location strategy by using provide method.

bootstrap(MyApp, [
  ROUTER_PROVIDERS,provide(LocationStrategy, {useClass: HashLocationStrategy})
]);

这篇关于如何通过在angular2打字稿改变路由器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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