當我用console.log在Firefox上測試我的index.html時,它會讀取一個奇怪的錯誤,我無法在Google Chrome或IE上運行。Firefox上的Angular.JS文檔元素錯誤後的垃圾
junk after document element
此錯誤是由main.html中頁面
<h1>This is my main</h1>
<h3>Scope value: {{ name }} </h3>
我剛學angular.js,其實我的代碼是完全一樣教程我下造成的,但我可以」弄清楚爲什麼不工作。任何人都可以點我正確的方向告訴我:
Why am I getting the console log error: Junk after document error, and why can't I make ngview and templateURL work on my site?
謝謝!
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', function($scope, $log) {
$scope.name = 'Main';
}]);
myApp.controller('secondController', ['$scope', '$log', function($scope, $log) {
$scope.name = 'Second';
}]);
INDEX.HTML
<header> <nav class="navbar navbar-default"> <div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">AngularJS</a>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><i class="fa fa-home"></i>Home</a></li>
<li><a href="#/second"><i></i>Second</a></li>
</ul> </div> </nav> </header>
<div class="container">
<div ng-view></div>
</div>
main.html中
因爲他們沒有做一個建在本地主機功能210<h1>This is my main</h1>
<h3>Scope value: {{ name }} </h3>
Second.HTML
<h1>This is my second</h1>
<h3>Scope value (on second page): {{ name }} </h3>