1

Normally if I click link on home link to detail link, like <a routerLink="/detail/{{record.TA001}}">,it work well and css file got very well.

As only I refresh this detail page, like localhost:3000/detail/0006 it got data ok, but get CSS file change the directory to the detail instead root directory, could not get the CSS file. My detail component is in app/content directory.

enter image description here

My index.html and CSS file in project root directory. router :

const appRoutes: Routes = [
  {
    path: 'contact',
    component: Contactcomponent
  },
  {
    path: 'detail/:id',
    component: Detailcomponent
  },
  { path: '',
   component: Contentcomponent
  }

My project directory is like this:

enter image description here

DimaSan
  • 12,264
  • 11
  • 65
  • 75
percinor
  • 227
  • 1
  • 2
  • 11

3 Answers3

0

i have known how to resolve this problem ,just router directive /detail/0005 change /0005, it woke fine . i think it was if router for root so you just can use one level just fine .it could not use two level approch , if u router not for root ,it can use it .

percinor
  • 227
  • 1
  • 2
  • 11
0

If you want to use relative path instead of calculating every time the absolute one (with ../ ../../ etc.) you should use moduleID property in your component declaration as explained here.

jspassov
  • 791
  • 7
  • 11
0

Check If u include base href="/" in index.html before including css/stylesheet