84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
angularjs中templateUrl的路径问题,一般都是写成绝对路径,有没有什么办法能写成相对路径的呢?
现在在做模块封装,有些常用部分写成了指令,希望在别的工程也能使用,但是这样就涉及到了html模板文件的路径问题,希望各位大大不吝赐教!
欢迎选择我的课程,让我们一起见证您的进步~~
templateUrl: absolute/path 建议改成 template: require('relative/path/template.html')
templateUrl: absolute/path
template: require('relative/path/template.html')
If the code is reused, I suggest you use template instead of templateUrl for two reasons
Easy to use. When using a third-party library, I generally hope to just introduce a js instead of following a bunch of stuff
Reduce http requests
As for code readability, it’s easily solved using module management and build tools
http://stackoverflow.com/questions/21835471/angular-js-directive-dynamic-templateurl
http://stackoverflow.com/questions/13681116/angularjs-dynamic-routing
templateUrl: absolute/path
建议改成template: require('relative/path/template.html')
If the code is reused, I suggest you use template instead of templateUrl for two reasons
Easy to use. When using a third-party library, I generally hope to just introduce a js instead of following a bunch of stuff
Reduce http requests
As for code readability, it’s easily solved using module management and build tools
http://stackoverflow.com/questions/21835471/angular-js-directive-dynamic-templateurl
http://stackoverflow.com/questions/13681116/angularjs-dynamic-routing