This is my index.cshtml (view to which I re-direct from the server side controller)

<!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>

My app and controller are as below

'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');
  }])

However when I try to load the Home view it gives following error:-

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

The path of the view is correct. Any suggestions?

share|improve this question
    
try templateUrl: 'Views/Home/Home.html' – Edminsson Aug 3 '14 at 10:13

try below templateUrl's

templateUrl: 'Views/Home/Home.html'

OR

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

OR

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

share|improve this answer
    
None of the above seem to work. Could it be some problem that the file which has the view has not loaded? Can I check whether that file has loaded or not? – user3264738 Aug 3 '14 at 10:38
    
404 for http://localhost:2614/Views/Home/Home.html this error means home.html is not found, you will have to solve this first... – harishr Aug 3 '14 at 10:40
    
yes, but I cant understand why this file is not loading? Do I need to do any additional step to load this file? It should load by default if its in my project right? – user3264738 Aug 3 '14 at 10:46
    
if your templateurl is correct then it must load. but somehow the browser/host is not getting to the file path – harishr Aug 3 '14 at 10:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.