小编pun*_*nov的帖子

Angular2路由器:将URL标签添加到url

我正在使用Angular2 Seed应用程序,你可以在官方的回购中找到它.如您所见,这里我们导入了angular2/router,我们正在使用它来创建应用程序的基本路由.

import {Component, ViewEncapsulation} from 'angular2/angular2';
import {
  RouteConfig,
  ROUTER_DIRECTIVES
} from 'angular2/router';
...
@RouteConfig([
  { path: '/', component: HomeCmp, as: 'Home' },
  { path: '/about', component: AboutCmp, as: 'About' }
])
export class AppCmp {}
Run Code Online (Sandbox Code Playgroud)

我的问题是:如何配置路由器在我的网址中添加主题标签,使其看起来像:localhost:5555 /#/ about.有没有美丽而简单的方法来制作它?(与之前的$ locationProvider一样)

我知道这很奇怪,但我曾经在网址中喜欢这个标签,而我的apache-config也曾经喜欢它.当然,我可以更改我的httpd.conf文件,非常简单和正确,但我真的想弄清楚,如何简单地添加hashtag,与Angular2路由器.

angular-routing angular-seed angular

3
推荐指数
1
解决办法
4894
查看次数

标签 统计

angular ×1

angular-routing ×1

angular-seed ×1