當我在/#/ addOrder中輸入URL時,它將加載模板文件。沒錯,我得到一些錯誤和索引頁面加載兩次。未找到路由控制器
t.html
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<title>asdad</title>
</head>
<body>
<div ng-app = "mainApp">
<a href="#/addOrder">add</a>
<div ng-view></div>
</div>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-route.min.js"></script>
<script src="{% static 'js/script.js' %}" type="text/javascript"></script>
</html>
tem.html
<h1>tem is loaded!</h1>
script.js
var mainApp = angular.module("mainApp", ['ngRoute']);
mainApp.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/addOrder', {
templateUrl: 'tem.html', controller: 'activeOrderController'
}).
when('/viewStudents', {
templateUrl: 'order/addOrders.html', controller: 'addOrderController'
}).
when('/viewStudents', {
templateUrl: 'order/endedOrders.html', controller: 'endedOrderController'
}).
otherwise({
redirectTo: '/t.html'
});
}]);
Error: ng:areq Bad Argument
Argument 'activeOrderController' is not aNaNunction, got undefined Description AngularJS often asserts that certain values will be present and truthy using a helper function. If the assertion fails, this error is thrown. To fix this problem, make sure that the value the assertion expects is defined and truthy.
不引起錯誤的控制器,但要注意你的'otherwise'需要在一個定義的有效角度URL時' ' – charlietfl