私は同じ問題に関連する投稿を読んでいますが、問題は解決しています。続き
は
<!DOCTYPE html>
<html ng-app="myModule">
<head>
<title></title>
<script src="Scripts/angular.js"></script>
<script src="Scripts/angular-route.js"></script>
<link href="Scripts/styles.css" rel="stylesheet" />
<meta charset="utf-8" />
</head>
<body>
<table style="font-family:Arial">
<tr>
<td class="header" colspan="2" style="text-align:center">Website Header</td>
</tr>
<tr>
<td class="leftMenu">
<a href="#/home">Home</a><br/>
<a href="#/courses">Courses</a><br />
<a href="#/students">Students</a><br />
</td>
<td class="mainContent">
<div><ng-view></ng-view></div>
</td>
</tr>
</table>
</body>
</html>
script.jsが
/// <reference path="angular-route.js" />
/// <reference path="angular.js" />
var myModule = angular.module("myModule", ["ngRoute"])
.config(function ($routeProvider) {
$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",
})
.controller("homeController", function ($scope) {
$scope.message = "HomePage";
})
.controller("coursesController", function ($scope) {
$scope.courses = ["c","c++","c#"];
})
.controller("studentsController", function ($scope) {
$scope.students = [{ name: "Chandu", id: 1, gender: "female" }, { name: "Suma", id: 2, gender: "female" }, { name: "Arin", id: 3, gender: "male" }];
})
})
私が定義した家、コースや学生のhtmlファイルをファイル私のindex.htmlファイルです。最初のローディングの後、例えばリンクのどれかをクリックすると。 homeに/#/ homeがURLに追加されていますが、部分テンプレートがロードされていません。
最初は、コンソールエラーも発生しませんでした。しかし、今、私はMyModuleというの名が正しく両方script.jsとのindex.htmlファイル
Uncaught Error: [$injector:modulerr] Failed to instantiate module myModule due to:
Error: [$injector:nomod] Module 'myModule' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.9/$injector/nomod?p0=myModule
で使用されていても、次のエラーを取得しています私は非常に私の問題を解決し、私は場所を見つけるのを助けるためにどのような援助に感謝します私は間違っている。
P.S:Index.htmlはメインディレクトリにあり、部分テンプレートはメインディレクトリのテンプレートフォルダにあります。そして、私はangular.jsとangular-route.jsのバージョン1.5.9を使用しています
私はangular.jsスクリプトのパスをhtmlファイルに追加しました – user3794853
あなたは追加する必要があることを示すために更新された回答 – rlcrews
私は見落とした私の側の愚かな間違いでした。助けてくれてありがとう。今私は作業コードを持っています! :-) – user3794853