I am developing a ASP.NET MVC - SPA website and I am using AngularJS. I have referred various articles given on the net. I am using ng-view, ngRoute and $routeProvider to achieve this but it is not working at all in my case. The code I have used for the routing is given below:
@{
Layout = "~/Views/Shared/_LayoutPersonal.cshtml";
}
@{
ViewBag.Title = "Index";
}
<h3>Questions</h3>
@*@Html.Action("Index","Question")*@
<div ng-app="overflowApp" ng-controller="overflowCtrl">
<p><a href="#/">Main</a></p>
<a href="#questions">Questions</a>
<a href="#users">Users</a>
<a href="#answers">Answers</a>
<div ng-view></div>
</div>
@section scripts{
<script>
function overflowController($scope, $http) {
$scope.testList = ['a', 'b'];
}
var overflowApp = angular.module("overflowApp", ['ngSanitize', 'ngRoute']);
overflowApp.controller("overflowCtrl", overflowController);
overflowApp.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
$routeProvider
.when("/questions", {
templateUrl : "../Question"
})
.when("/users", {
templateUrl: "../Questions/users"
})
.when("/answers", {
templateUrl: "../Questions/answers"
});
}]);
</script>
}
The URLs being displayed when I hover over the hyperlinks look like http://localhost:49910/#/questions and it doesn't load the view it is supposed to. Please help me out.
templateUrl: Questions, because that should be a request for ASP.NET MVC to handle to be able to return the compiled HTML from the Razor view.