Angular2 Routing : Loading twice

前端 未结 1 466
Happy的楠姐
Happy的楠姐 2020-12-19 04:23

I am using Angular2 with routing and my page is showing duplicate content on initial load. Once i click any Link(Page1 or Page2) everything works perfect(there is no more du

相关标签:
1条回答
  • 2020-12-19 04:52

    The AppComponent shouldn't be part of the routing. It's what holds the root outlet.

    { path: '', component: AppComponent },
    

    What you should do instead for the base path, is decide what component/path should be the default view, then redirect to the path. For instance if the page1 should be the default view, then do

    { path: '', redirectTo: 'page1', pathMatch: 'full' },
    
    0 讨论(0)
提交回复
热议问题