1

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'
        });
  }]);

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

$locationProvider is in core ng module so you don't have to include any other module in order to use $locationProvider.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.