Angular2 rc3中的HashLocationStrategy不起作用

时间:2016-06-24 05:04:39

标签: angular routing

Angular2 rc3中的HashLocationStrategy无法正常工作

import {provide} from '@angular/core';
import {LocationStrategy, HashLocationStrategy} from '@angular/common';
...
bootstrap(AppComponent, [
    disableDeprecatedForms(),
    provideForms(),
    provide(LocationStrategy, { useClass: HashLocationStrategy }),
    APP_ROUTER_PROVIDERS
]);

但链接是在没有#的情况下生成的 我想使用新的路由器(" @ angular / router":" 3.0.0-alpha.7")

1 个答案:

答案 0 :(得分:0)

尝试使用以下配置:

bootstrap(AppComponent, [
    disableDeprecatedForms(),
    provideForms(),
    {provide: LocationStrategy, useClass: HashLocationStrategy},
    APP_ROUTER_PROVIDERS
]);