我正在使用angularjs路由,但得到以下错误...
<title>Angular js</title>
</head>
<body><div data-ng-controller="SimpleController">
<div data-ng-view=""></div>
NAme:<input type="text" data-ng-model="name" />{{name}}
<br />
<ul>
<li data-ng-repeat="cust in customers|filter:name|orderBy:'city'">{{cust.name|uppercase}}-{{cust.city|lowercase}}</li>
</ul>
<script>
var demoapp = angular.module('demoapp', ['ngRoute']);
demoapp.config(function($routeprovider){
$routeprovider
.when('/',{
controller:'SimpleController',
templateUrl:'view1.html'
})
.when('/partial2',{
controller:'SimpleController',
templateUrl:'view2.html'
})
.otherwise({redirectTo:'/'});
});
demoapp.controller('SimpleController',
function ($scope) {
$scope.customers = [{ name: 'aman', city: 'boom' },
{ name: 'ajay', city: 'reem dee' },
{ name: 'hood', city: 'meen' }];
});
</script>
</div>
</body>
</html>
控制台上的错误
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.12/$injector/modulerr?p0=demoapp&p1=Error%3…0Yb%20(http%3A%2F%2Flocalhost%3A4257%2Fscripts%2Fangular.min.js%3A32%3A232)
答案 0 :(得分:8)
请务必在angular.js
之后加入angular-route.js
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.12/angular-route.js"></script>
将$routeprovider
替换为$routeProvider
。通过使用服务作为依赖项,它不能注入错误的参数名称。