Angular2 routing - adding the hashtag using LocationStrategy not working?

前端 未结 2 1544
清酒与你
清酒与你 2020-12-21 03:54

I\'m following the simple quickstart app from the Angular2 docs and I\'m using a spring backend to run it. My problem is that the angular router ditched the hashtag from the

相关标签:
2条回答
  • 2020-12-21 04:36

    With your implementation everything seems perfect.
    Now, Please try to delete browser's cache memory and try. I hope it will start working !!!
    I faced this problem when trying for your problem.

    0 讨论(0)
  • 2020-12-21 04:52

    Angular2 <= RC.5

    The ROUTER_PROVIDERS need to be added before LocationStrategy otherwise your previously added LocationStrategy gets overridden.

    bootstrap(
        TestComponent, 
        [
            ROUTER_PROVIDERS, 
            // must be listed after `ROUTER_PROVIDERS`
            provide(LocationStrategy, { useClass: HashLocationStrategy })
        ]
    );
    

    delete this line

    providers: [ROUTER_PROVIDERS]
    

    from TestComponent

    0 讨论(0)
提交回复
热议问题