Reputation: 12448
This is a seriously dumb question, but I always struggle with this so hopefully someone can help.
When creating my angular app I understand that in order to inject the correct provider, I first need to include it/require it when I define my module.
Here is an example - here I require the $routeProvider, so I include ngRoute:
var sampleApp = angular.module('phonecatApp', ['ngRoute']);
sampleApp.config(['$routeProvider',
function ($routeProvider) {
$locationProvider.html5Mode(true);
$routeProvider.
when('/about', {
templateUrl: 'home/about',
controller: 'AddOrderController'
}).
when('/contact', {
templateUrl: 'home/contact',
controller: 'ShowOrdersController'
}).
otherwise({
redirectTo: '/about'
});
}]);
Now I additionally require the $locationProvider but don't know what module to include, I look in all the angularjs docs and try ngLocation but no luck! My question (is not which module do I need for location) but rather how do I find out from the angular docs which module I need for any given provider?
I cant figure it out from the crazy documentation?
var sampleApp = angular.module('phonecatApp', ['ngRoute', '?????']);
sampleApp.config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.
when('/about', {
templateUrl: 'home/about',
controller: 'AddOrderController'
}).
when('/contact', {
templateUrl: 'home/contact',
controller: 'ShowOrdersController'
}).
otherwise({
redirectTo: '/about'
});
}]);
Upvotes: 1
Views: 443
Reputation: 724
Here you can find the documentation for the $locationProvider
. At the top of the screen, below the title $locationProvider, it says the module where you can find this function, it says "provider in module ng", which means it is part of the core.
Upvotes: 1
Reputation: 208
$locationProvider
is in core ng
module so you don't have to include any other module in order to use $locationProvider
.
Upvotes: 0
Reputation: 594
In the API Reference the module names are listed as headings in the left navigation: https://docs.angularjs.org/api
For example you can see ngRoute there, and see that $locationProvider is included in the ng module.
Upvotes: 1