我有一个 Angular 2 应用程序,我正在使用旧templateUrl
的从同一服务器上的 URL 加载 HTML 模板。
templateUrl: '/components/directive/directive.html'
我/loaded/path/
在我的指令加载的路径上。
它曾经在 Angular 1 中工作正常,但在 Angular 2 中它会抛出此错误
Could not resolve the url /components/directive/directive.html from http://example.com/loaded/path/
Error
at new BaseException (http://example.com/angular2.sfx.dev.js:10986:25)
at UrlResolver.System.register.execute.UrlResolver.resolve
我想一种解决方案是添加../../
templateUrl: '../../components/directive/directive.html'
但是如果我在/some/other/loaded/path
使用指令的地方怎么办
有没有办法告诉 Angular 2 从根而不是当前路径解析路径?