2015-09-28 29 views
0

這是我的角度的應用程序文件,其中添加我的路由:角航線找不到觀點

(function() { 
var app = angular.module("CustCMS", ["ngRoute"]); 

app.config(function ($routeProvider) { 
    $routeProvider 
     .when("/Index", { 
      templateUrl: "~/CustCMS/Views/User/Index.html", 
      controller: "IndexController" 
     }) 
     .when("/User/:userid", { 
      templateUrl: "~/CustCMS/Views/User/User.html", 
      controller: "UserController" 
     }) 
     .otherwise({ redirectTo: "/Index" }); 
}); 
}()); 

我已經嘗試了一些不同的方式進入templateUrl但我總是得到這個錯誤:

[$compile:tpload] Failed to load template: ~/CustCMS/Views/User/Index.html (HTTP status: 404 Not Found) 

enter image description here

我有什麼進入了templateUrl找到我的看法?

+0

你嘗試過'templateUrl:「/Views/User/Index.html」,'? – webduvet

+0

是的。我dosn't工作要麼:( –

回答

0

因爲您在某個文件夾中包含您的index.html。改變否則路線

/CustCMS/Views/User/Index.html. 
1

所以我發現的answere。 Angular無法處理cshtml文件,因此您必須使用靜態視圖。由於Visual Studio中有一些約束,因此您無法在視圖文件夾中獲得靜態視圖,因此您必須創建另一個文件夾並將靜態視圖添加到該文件夾​​中。