0
我不確定這是否重複,但我真的似乎無法解決這個錯誤。我一直在關注AngularJS Fundamentals In 60-ish Minutes。它運行良好,直到我路由。我一直得到未被捕獲的錯誤:沒有模塊和未捕獲的語法錯誤:意外的標記(當我檢查鉻控制檯)。看起來好像路由沒有正常工作,因爲在訪問UsingDirectives.html之後view1不會被訪問。未被捕獲的錯誤:沒有模塊
UsingDirectives.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html data-ng-app="demoApp">
<head>
<title>Using angular contoller</title>
</head>
<body>
<div>
<!--Placeholder for views -->
<data-ng-view></data-ng-view>
</div>
<script src="lib/angular.js"></script>
<script>
var demoApp = angular.module('demoApp', []);
demoApp.config(function ($routeProvider){
$routeProvider
.when('/',
{
controller: 'SimpleController',
templateUrl: 'partials/view1.html'
})
.when('/view2',
{
controller: 'SimpleController',
templateUrl: 'partials/view2.html'
})
.otherwise({redirectTo: '/'});
});
demoApp.controller('SimpleController', function($scope)){
$scope.customers = [
{ name: 'John Smith', city: 'Phoenix'},
{ name: 'John Doe', city: 'New York'},
{ name: 'Jane Smith', city: 'San Fran'}
];
$scope.addCustomer = function() {
$scope.customers.push(
{
name: $scope.newCustomer.name,
city: $scope.newCustomer.city
});
};
}
</script>
</body>
</html>
view1.html(它是在文件夾中所謂的諧音):
<div class='container">
<h2>View 1</h2>
Name:
<br />
<input type ="text" data-ng-model="filter.name" />
<br />
<ul>
<li data-ng-repeat="cust in customers | filter:filter.name">{{cust.name}} - {{cust.city}}
</ul>
<br />
Customer Name:<br />
<input type="text" data-ng-model="newCustomer.name" />
<br />
Customer City:<br />
<input type="text" data-ng-model="newCustomer.name" />
<br />
<button data-ng-click="addCustomer()"> Add Customer </button>
<br />
<a href = "#/view2"> view 2</a>
</div>
我使用eclipse
後完整的錯誤消息,告訴uw他們引用哪一行,並嘗試創建一個plunkr。 –