Reputation: 466
I defined an angular module and angular keeps complaining about a missing "$routeProvider". I don't understand as i defined the 'ngRoute' as dependency of my module.
My Code:
(function () {
'use strict';
var FlightlistController = function () {
//code comes inside here
};
angular.module('flights', ['ngRoute'])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/flightslist', {
controller: 'FlightsController',
controllerAs: 'flights',
templateUrl: 'modules/flight/list.view.html'
})
}])
.controller('FlightsController', ['$routeProvider', FlightlistController])
})();
Upvotes: 1
Views: 722
Reputation: 3783
Please remove the $routeProvider
from controller definition.
.controller('FlightsController', ['$routeProvider', FlightlistController])
just use
.controller('FlightsController', FlightlistController);
Hope this helps now.
Upvotes: 1
Reputation: 82
You need to specify the input parameter of the controller (function FlightlistController).
var FlightlistController = function () need to be changed to var FlightlistController = function ($routeProvider)
And as per your error message check have you specify the script reference for ngRoute. if not place it after you add the script reference of angular.
Upvotes: 0
Reputation: 2777
You forgot to inject it in your controller function as a param
(function () {
'use strict';
var FlightlistController = function ($routeProvider) {
//code comes inside here
};
angular.module('flights', ['ngRoute'])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/flightslist', {
controller: 'FlightsController',
controllerAs: 'flights',
templateUrl: 'modules/flight/list.view.html'
})
}])
.controller('FlightsController', ['$routeProvider', FlightlistController])
})();
Upvotes: 0