I have created an MVC application and added an Angularjs nuget. It was created HomeController and view for it. Home controlled isn't changed at all. My folder hierarchy:
Index.cshtml:
<!DOCTYPE html>
<html>
<head>
<script src="~/Scripts/angular.js"></script>
<script src="~/Scripts/angular-route.js"></script>
<script src="~/Scripts/App/App.js"></script>
<title>Title</title>
</head>
<body ng-app="sampleApp">
<a href="#/route1">Route 1</a><br />
<a href="#/route2">Route 2</a><br />
<div ng-view></div>
<script>
var module = angular.module("sampleApp", ['ngRoute']);
module.config(
function ($routeProvider, $locationProvider) {
$routeProvider.
when('/route1', {
templateUrl: 'Views/Home.html',
controller: 'RouteController'
}).
when('/route2', {
templateUrl: 'Views/Home.html',
controller: 'RouteController'
}).
otherwise({
redirectTo: '/'
});
});
module.controller("RouteController", function ($scope) {
alert("I am here");
})
</script>
</body>
</html>
Clicking on the links produces an 404 error
http://localhost:50265/Home/Views/Home.html - this is link that was generated.
I don't understand why there is Home inserted in link.
And as the page of error said that it expected physical path
E:\SoftServe\IndividualTask\IndividualTask\Home\Views\Home.html
but i don't have Home folder in root folder E:\SoftServe\IndividualTask\IndividualTask
I set the route to 'Views/Home.html' but not to 'Home/Views/Home.html'.
What is the base path for routing? How to make it work?
