0
我有以下的HTML頁面:路由使用AngularJS
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>
<body ng-app="myApp">
<p><a href="/">Main</a></p>
<a href="first">City 1</a>
<a href="#first">City 1a</a>
<div ng-view></div>
<script>
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider
.when("/first", {
templateUrl : "first.html"
})
.when("/first", {
templateUrl : "first.html"
});
});
</script>
</body>
</html>
然後有一個簡單的頁面first.html。 現在,我的City1a
鏈接工程和angularJS正確加載頁面到<div ng-view></div>
。相反,city1
鏈接不起作用,我有404錯誤。我的網址是http://localhost/myproject/index.html#/first
。我能做些什麼來打開http://localhost/myproject/first
的URL?
它不起作用。我沒有404錯誤,但沒有加載first.html頁面。 – DistribuzioneGaussiana
和哪個錯誤被拋出? – VahagnNikoghosian