Reputation: 13
HTML
<!DOCTYPE html>
<html ng-app="adaniapp">
<head>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/font-awesome.css" />
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="main">
<div ng-view></div>
</div>
<script src="js/angular.min.js"></script>
<script src="js/angular-route.js"></script>
<script src="js/angular-resource.min.js"></script>
<script src="js/app.js"></script>
</body>
</html>
Javascript
var adaniapp = angular.module('adaniapp', ['ngRoute','ngResource']);
// configure our routes
adaniapp.config(['$scope', '$routeProvider', '$resource',function($scope, $routeProvider, $resource) {
$routeProvider
// route for the home page
.when('/', {
templateUrl : 'page/login.html',
controller : 'mainController'
})
// route for the about page
.when('/home', {
templateUrl : 'page/home.html',
controller : 'HomeController'
})
// route for the contact page
.when('/meter', {
templateUrl : 'page/meter.html',
controller : 'MeterController'
})
.when('/viewbill', {
templateUrl : 'page/viewbill.html',
controller : 'ViewbillController'
});
}]);
// create the controller and inject Angular's $scope
adaniapp.controller('mainController',['$scope', '$routeProvider', '$resource', function($scope, $routeProvider, $resource) {
}]);
adaniapp.controller('HomeController',['$scope', '$routeProvider', '$resource', function($scope, $routeProvider, $resource) {
}]);
adaniapp.controller('MeterController',['$scope', '$routeProvider', '$resource', function($scope, $routeProvider, $resource) {
}]);
adaniapp.controller('MeterController',['$scope', '$routeProvider', '$resource', function($scope, $routeProvider, $resource) {
}]);
included ng-resource.js file and route.js file are included in index.html, but still its showing error in my console as
"Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0="
all controller included.
Upvotes: 0
Views: 669
Reputation: 2954
$scope
during configuration phase.Configuration blocks - get executed during the provider registrations and configuration phase. Only providers and constants can be injected into configuration blocks. This is to prevent accidental instantiation of services before they have been fully configured.
$routeProvider
in controllers since it is already configured, use $route
service instead.Upvotes: 0
Reputation: 10202
I'm guessing you're actually missing some scripts. Try bower installing them or add them manually if not using bower. Missing angular-route.js
, which is not included with angular, is especially common. If there are any 404's in your web developer console, they would help confirm that suspicion (although there's a small chance your web server might not be serving them as 404's if it's configured in an unusual way).
Upvotes: 1