我已经搜索了很多帖子,但仍然无法运行非常基本的自定义指令,因为templateUrl
未正确解析。使用angularJS和asp.net解析相对模板网址MVC
我有一个AngularJSController
与索引行动(asp.net MVC),调用View/AngularJS/Index.cshtml,非常基本。在那里,我调用自定义指令:
<product-title></product-title>
其概括喜欢这样:
app.directive('productTitle', function() {
return {
restrict: 'E',
// ends up with wrong url '{root-path}/AngularJS/AngularJSTemplates/ProductTitle'
templateUrl: 'AngularJSTemplates/ProductTitle'
}
});
正如你所看到的,它应该调用控制器AngularJSTemplatesController
(asp.net MVC)与操作方法ProductTitle
。这将返回我的部分angularJS。 这里的问题是: AngularJS电话{root-path}/AngularJS/AngularJSTemplates/ProductTitle
代替{root-path}/AngularJSTemplates/ProductTitle
...
我是缺少在这里?我真的需要将某处的根路径定义为JavaScript全局,并将其用于绝对路径吗?
都能跟得上那现在肯定是错误的文件... – sl3dg3 2014-08-31 18:10:49