Hash Location Strategy in Angular 2

后端 未结 4 785
梦如初夏
梦如初夏 2020-12-06 18:16

I\'m trying to create an application with hash location strategy, but it does not add the hash to the url. For instance when I click on a button associated with { path: \'/p

4条回答
  •  情歌与酒
    2020-12-06 18:54

    ROUTER_PROVIDERS should not be added to child components,

    only to

    providers: [ROUTER_PROVIDERS]
    

    or alternatively only to

    bootstrap(AppComponent, [ROUTER_PROVIDERS]);
    

    HTTP_PROVIDERS are in my opinion also a better fit for root component or bootstrap() but it doesn't break anything to add them somewhere else.

    (See also Routing error with angular 2 and IIS)

提交回复
热议问题