angular.js - angularjs中templateUrl的路径问题
天蓬老师
天蓬老师 2017-05-15 17:01:08
0
3
633

angularjs中templateUrl的路径问题,一般都是写成绝对路径,有没有什么办法能写成相对路径的呢?

现在在做模块封装,有些常用部分写成了指令,希望在别的工程也能使用,但是这样就涉及到了html模板文件的路径问题,希望各位大大不吝赐教!

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(3)
淡淡烟草味

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

Ty80

http://stackoverflow.com/questions/21835471/angular-js-directive-dynamic-templateurl

http://stackoverflow.com/questions/13681116/angularjs-dynamic-routing

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!