view - Angular2 relative paths for templateUrl and styleUrls? -


while searching found named moduleid set relative paths of template , css files, don't know how use moduleid in our components of angular2?

actually, problem in folder structure.i loading .js files dist folder whereas view(.html files) in src folder. when use moduleid: module.id angular took path dist folder, instead of src folder.

so here helps me tell how set custom moduleid component angualr2?

my folder structure this.

                                  app                                   /\                                  /  \              (.js + .map files)dist    src(.ts + .html + .css files) 
  • folder dist containes .map , .js files
  • folder src containes .ts, .html, , .css file.

actual coding (working) -

@component({     selector: 'class-timing',     templateurl: 'src/components/timetable/class-timing/class-timing.html',     styleurls: ['src/app.css'] }) 

modified coding (not working due incorrect path) -

@component({     selector: 'class-timing',     templateurl: 'class-timing.html',     moduleid: module.id,     styleurls: ['src/app.css'] }) 

referring tutorial http://schwarty.com/2015/12/22/angular2-relative-paths-for-templateurl-and-styleurls/

resolved problem changing path (from src dist)of importing file @ run time :-

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

by doing can change path directory of module id.

thanks @nicolai awesome comment

ps:- posting answer may someone


Comments