This my app.js,
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(function($routeProvider){
$routeProvider.when('/',{
templateUrl: 'views/home.html',
controller: 'homeCtrl'
}).when('/detail',{
templateUrl: 'views/details.html',
controller: 'detailCtrl'
}).otherwise({
redirectTo: '/home'
});
});
myApp.controller('homeCtrl',function($scope){
$scope.message ="Welcome to your Home Page"
});
myApp.controller('detailCtrl',function($scope){
$scope.message ="Name: Manish"
});
This is index.html page,
<html >
<head>
<meta charset="ISO-8859-1">
<title>Try It Out</title>
<script type="text/javascript" src="js/angular.js"></script>
<script type="text/javascript" src="js/angular-route.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</head>
<body ng-app="myApp" ng-controller="homeCtrl" style="text-align: center;">
<span ><a href="/">{{message}}</a></span><br>
<a href="#/">Home</a>
<a href="#/detail">Details</a>
<br><br>
<div ng-view></div>
<h4>copyright 2017</h4>
</body>
</html>
this is my home.html
<h3>Home</h3><br>
{{message}}
same in details.html
<h3>Details</h3><br>
{{message}}
problem is when i run it on server its going to home page at first.but when i click on details..its not showing message of Details.html. and main problem is with URL...clicking on Details link..
http://localhost:7675/AngularJSinglePage/#!/#%2Fdetail
As u can notice "!/#%2F" this comes in between..don't know from where,it should come like this
http://localhost:7675/AngularJSinglePage/#/detail
Any one faced same problem? Help me out, I am trying to learn SPA using AngularJS?