私はビジュアルスタジオと崇高なテキストでコードを試しましたが、開発ツールにエラーは表示されませんでしたが、私はhome.htmlのために他のhtmlページを挿入しようとしましたが、 。ここに私が参考にしたコードがあります。アドレスバーには、このようなものです:私は勉強のオンラインチュートリアルのhttp://localhost:63928/Index.html#!#%2Fhomeしばらくは/#ホームバーを含み、ここでangularjs routing - not working
あるindex.htmlを:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="Demo">
<head>
<title></title>
<script src="Scripts/angular.min.js"></script>
<script src="Scripts/angular-route.min.js"></script>
<link href="Styles.css" rel="stylesheet" />
<script src="Scripts/Script.js"></script>
</head>
<body>
<table style="font-family: Arial">
<tr>
<td colspan="2" class="header">
<h1>
WebSite Header
</h1>
</td>
</tr>
<tr>
<td class="leftmenu">
<a href="#/home">Home</a>
<a href="#/courses">Courses</a>
<a href="#/students">Students</a>
</td>
<td class="maincontent">
<ng-view></ng-view>
</td>
</tr>
<tr>
<td colspan="2" class="footer">
<b>Website Footer</b>
</td>
</tr>
</table>
</body>
</html>
私のStyles.cssを
.header {
width: 800px;
height: 80px;
text-align: center;
background-color: #BDBDBD;
}
.footer {
background-color: #BDBDBD;
text-align: center;
}
.leftmenu {
height: 500px;
background-color: #D8D8D8;
width: 150px;
}
.maincontent {
height: 500px;
background-color: #E6E6E6;
width: 650px;
}
a {
display: block;
padding: 5px
}
Script.js
/// <reference path="angular.min.js" />
var app = angular
.module("Demo", ["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 = "Home Page";
})
.controller("coursesController", function ($scope) {
$scope.courses = ["C#", "VB.NET", "ASP.NET", "SQL Server"];
})
.controller("studentsController", function ($scope, $http) {
$scope.students = ["Chiku", "Veeru", "ASHA", "SAchin"];
})
とhome.html が含まれています:
<h1>{{message}}</h1>
courses.html :
<h1>Courses we offer</h1>
<ul>
<li ng-repeat="course in courses">
{{course}}
</li>
</ul>
students.html
<h1>List of Students</h1>
<ul>
<li ng-repeat="student in students">
{{student}}
</li>
</ul>
誰かがfindoutことができる場合にエラーが おかげで私に役立つだろう。
使用している角度のjsのバージョンは何ですか? –