В моем приложении angularjs у меня есть index.html в общей папке с кодом ниже,
<body ng-controller="TheController">
<div id="startdiv">
<label>Username</label><input type="text" tabindex="1" placeholder="Enter Your User Name" name="email" required>
<label>Password</label><input type="password" tabindex="2" placeholder="Enter Your Password" name="password" required>
<br><br>
<button ng-click="saveData()">Login</button><button ng-click="saveData()">SignUp</button><br>
<button ng-click="changeview()">ClickMe</button>
</div>
</body>
И часть сценария, как показано ниже,
var app = angular.module('plunker',['ngRoute']);
app.config(['$locationProvider', function($locationProvider) {
$locationProvider.hashPrefix('');
}]);
app.config(function($routeProvider) {
$routeProvider
.when("/test", {
templateUrl : "index.html"
})
.when("/london", {
templateUrl : "london.html",
});/*
.otherwise({
redirectTo: '/paris.html'
}); */
});
app.controller('TheController', function ($scope,$location) {
console.log('hello')
$scope.changeview = function () {
console.log('in functgion changeview')
console.log($location)
$location.path('/london');
}
});
Также у меня есть london.html в той же общедоступной папке, которую я хочу загрузить при нажатии кнопки.
мой london.html
<h1>London</h1>
<h3>London is the capital city of England.</h3>
Проблема в том, что при нажатии кнопки URL-адрес изменяется с "http://localhost:3000/" на " http://localhost:3000/#/london ", но страница html не загружается. Также я хочу знать, можно ли выполнить маршрутизацию с помощью символа решетки.
Пожалуйста, дайте мне знать, где я ошибаюсь. Спасибо.