Angular2 relative paths for templateUrl and styleUrls?

后端 未结 2 472
北海茫月
北海茫月 2020-12-09 14:36

While searching I found something named as moduleId to set the relative paths of template and CSS files, but I don\'t know exactly how to use moduleId

相关标签:
2条回答
  • 2020-12-09 14:37

    Resolved my Problem by changing path (from src to dist)of importing file at the run time like this :-

    moduleId: module.id.replace("/dist/", "/src/")
    

    By doing so you can change path directory of module ID.

    thanks to @Nicolai for this awesome comment

    PS:- Posting as answer may help someone

    0 讨论(0)
  • 2020-12-09 14:38

    I also had some questions about what worked and didn't work for TemplateUrl paths. I found the following was true in my testing:

    templateUrl: 'folder name / file name' did not work

    templateUrl: '/folder name / file name' did not work

    templateUrl: './folder name / file name' DID work

    so you might try that out.

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