が見つかりませんURL私はindex.html
のパスがProjectName/index.html
で、私の他html
ファイルがprojectName/templates/xxx.html
であり、私のscript.js
パスがindex.html
.MYベースreferneceラインと同じですシンプルAngularJS
プロジェクトを作成しました<base href="/Projectname/">
ですが、ページをリフレッシュすると、ページが見つかりませんでした。エラーです。 ホームページと生徒のページをリロードするとエラーが発生します。がエラー
Myindex.htmlコード
<!DOCTYPE html>
<html ng-app="myModule">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<base href="/routing/">
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular-route.min.js"></script>
<script type="text/javascript"
src="script.js"></script>
</head>
<body>
<table style="">
<tr style="background-color: gray;">
<th colspan="2" class="header"><h1>Header</h1></th>
</tr>
<tr>
<td class="leftMenu" style="background-color: #cecece;"><a
href="home">Home</a> <a href="courses">Courses</a> <a
href="students">Students</a></td>
<td class="mainContent" colspan="2"
style="background-color: lightgray;"><ng-view></ng-view> </td>
</tr>
<tr style="background-color: gray;">
<td colspan="2" class="footer"><b>Website Footer</b></td>
</table>
</body>
</html>
マイscript.js
var app = angular
.module("myModule", [ "ngRoute" ])
.config(function($routeProvider, $locationProvider) {
$routeProvider.when("/home", {
templateUrl : "Templates/home.html",
controller : "homeController"
}).when("/courses", {
templateUrl : "Templates/courses.html",
controller : "coursesController"
}).when("/students", {
templateUrl : "Templates/students.html",
controller : "studentsController"
}).when("/students/:id", {
templateUrl : "Templates/studentDetails.html",
controller : "studentDetailsController"
}).otherwise({
redirectTo : "/home"
})
$locationProvider.html5Mode(true);
})
.controller("homeController", function($scope) {
$scope.message = "Home page";
})
.controller("coursesController", function($scope) {
$scope.courses = [ "c#", "Android", "Java", "Html", "PHP" ];
})
.controller(
"studentsController",
function($scope, $http) {
$http
.get(
"http://localhost/angulartest/services/api.php?list")
.then(function(response) {
$scope.students = response.data;
});
})
.controller(
"studentDetailsController",
function($scope, $http, $routeParams) {
$http(
{
url : "http://localhost/angulartest/services/api.php",
method : "get",
params : {
id : $routeParams.id
}
}).then(function(response) {
$scope.student = response.data;
$scope.message = "student details";
console.log($scope.student);
})
});
のNd home.htmlのような私の他のhtmlファイル、students.htmlは/パスプロジェクト名/テンプレートでテンプレートフォルダに用意されていxxx.html
どのページを更新しましたか?あなたはどのページにいますか? plsは質問にいくつかの詳細を追加します。 – Sravan
[Reloading the page]の重複した可能性がありますAngularJS HTML5モードで間違ったGETリクエスト](http://stackoverflow.com/questions/16569841/reloading-the-page-gives-wrong-get-request-with-angularjs-html5-モード) – Brian