我已經搜索了很多帖子,但仍然無法運行非常基本的自定義指令,因爲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