查看未加载角度js应用程序

时间:2014-08-03 10:07:51

标签: asp.net-mvc angularjs asp.net-mvc-4

这是我的index.cshtml(我从服务器端控制器重定向的视图)

<!DOCTYPE html>

<html lang="en" ng-app="AlumnusApp" class="no-js">
<head>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular-route.js"></script>
     <script src="~/Scripts/AlumnusScripts/AlumnusApp.js"></script>
    <script src="~/Scripts/AlumnusScripts/AlumnusController.js"></script>

  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>My AngularJS App</title>
</head>
<body>
    <div></div>
  <div ng-view></div>


</body>
</html>

我的应用和控制器如下

'use strict';

// Declare app level module which depends on filters, and services
angular.module('AlumnusApp',['ngRoute']).
config(['$routeProvider', function ($routeProvider) {
    debugger;
    $routeProvider.when('/Home', { templateUrl: '/Views/Home/Home.html', controller: 'HomeCtrl' });
    $routeProvider.otherwise({ redirectTo: '/Home' });
}]);



/* Controllers */

angular.module('AlumnusApp')
  .controller('HomeCtrl', ['$scope', function ($scope) {
      alert('1');
  }])

但是,当我尝试加载Home视图时,它会出现以下错误: -

http://localhost:2614/Views/Home/Home.html 404 (Not Found)  

视图的路径是正确的。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

尝试下面的templateUrl的

  

templateUrl:'Views / Home / Home.html'

OR

  

templateUrl:'/ Views / Home / Home.html'

OR

  

templateUrl:'.. / Views / Home / Home.html'