角度jsでルーティングを実行しようとしていますが、Serverはうまく動作しています。しかし、角度ルーティングは正しく動作していません、main.htmlページだけがng-viewに来て、second.htmlは来ていません。同じmainControllerの第1と第2をクリックすると、secondControllerではなく、動作しています。 角度ルーティングが正しく機能していませんか?
<h1> this is second </h1>
HTML
<!Doctype html>
<html ng-app="myApp">
<meta charset=utf-8" />
<head>
<script src="http://code.angularjs.org/snapshot/angular.min.js"></script>
<script src="http://code.angularjs.org/snapshot/angular-route.min.js">
</script>
<script type="text/javascript"src="app.js"></script>
<body>
<header>
<li><a href="#/"><i></i>first</a></li>
<li><a href="#/second"><i></i>Second</a></li>
</header>
<div class = "container">
<div ng-view>
</div>
</body>
main.htmlを
<h1> this is main </h1>
second.html app.js
var myApp = angular.module('myApp',['ngRoute']);
myApp.config(function ($routeProvider){
$routeProvider
.when('/',{
templateUrl: 'pages/main.html',
controller: 'mainController',
})
.when('/second',{
templateUrl: 'pages/second.html',
controller: 'secondController',
})
});
myApp.controller('mainController',
['$scope','$log','$location',function($scope,$log,$location){
$log.info($location.path());
console.log("first");
}]);
myApp.controller('secondController',
['$scope','$log','$location',function($scope,$log,$location){
$log.info($location.path());
console.log("second");
}]);
あなたのコンソールにエラーを得たのですか? – Zooly
"secondController"はどこですか? –