search

Home  >  Q&A  >  body text

angular.js - Path problem of templateUrl in angularjs

The path problem of templateUrl in angularjs is generally written as an absolute path. Is there any way to write it as a relative path?

Now I am doing module encapsulation. Some common parts are written as instructions. I hope they can be used in other projects. However, this involves the path problem of the html template file. I hope you will give me some advice!

天蓬老师天蓬老师2794 days ago680

reply all(3)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-15 17:03:08

    templateUrl: absolute/path 建议改成 template: require('relative/path/template.html')

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 17:03:08

    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

    reply
    0
  • PHP中文网

    PHP中文网2017-05-15 17:03:08

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

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

    reply
    0
  • Cancelreply