【发布时间】:2017-05-22 05:14:47
【问题描述】:
我一直在尝试在 Razor 视图 MVC 5 中调用 angularjs 自定义指令 templateUrl,但无法获取文件。 在我的项目中,我使用没有 $routeProvider 或 angularjs 路由的 angularjs,因为我的应用程序直接依赖于 mvc 路由。 有人可以帮我解决这个问题吗?
These are my templates....
~/Areas/Sales/Views/Orders/Edit.cshtml ~/Areas/Sales/Views/Orders/Add.cshtml ~/Areas/Sales/Views/Orders/Update.cshtml ~/Areas/Sales/Views/Orders/Delete.cshtml
This is my directive.
app.directive("test", function(){
return{
restrict:'AE',
scope: {
emp: '='
},
templateUrl: '~/Areas/Sales/Views/Orders/Edit.cshtml'
}
});
【问题讨论】:
-
Claies,我只是想在 MVC 5 中使用带有 templateUrl 选项的指令,但不知道如何在此处加载 templateUrl 文件。你能解释一下吗?
-
Claies,你能提供任何可行的例子吗?
-
Claies,你能建议我正确的方法吗,因为我即将创建很多指令,所以在此之前我想清楚在mvc 5
-
Claies,复制一下,但是如何在 MVC 5 的 templateUrl 中调用 .html 文件?
-
Claies,我真的要对我的域名或 FQDN 进行硬编码吗?
标签: javascript angularjs asp.net-mvc angularjs-directive