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
in our components of angular2?
Actually, the problem is in my folder structure.I am loading my all .js files from dist
folder whereas my view(.html files) are in the src
folder. So when I use moduleId: module.id
like this angular took the path from dist
folder, instead of src folder.
So anybody here helps me tell that How to set custom moduleId for my component angualr2?
My folder structure like this.
App
/
/
(.js + .map files)Dist Src(.ts + .html + .css files)
- Folder Dist containes all .map and .js files
- Folder src containes all .ts, .HTML, and .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 to incorrect path) -
@Component({
selector: 'class-timing',
templateUrl: 'class-timing.html',
moduleId: module.id,
styleUrls: ['src/app.css']
})
Referring to this tutorial
http://schwarty.com/2015/12/22/angular2-relative-paths-for-templateurl-and-styleurls/
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…