当使用templateUrl时,让Angular 2从root而不是当前路径解析基本路径

时间:2015-05-27 20:13:07

标签: angular

我有一个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解决从根而不是当前路径的路径?

0 个答案:

没有答案