AngularJS: Difference between $ route and $ routerProvider?

Can someone explain me the difference between $route and $routeProvider ?

+4
source share
2 answers

Services are singles. They are created the first time they are needed. Sometimes you need to configure a service before starting it, for example, in the .config part of the application module. Here you are using $routeProvider . After that, you can normally use the service instance (for example, $route ), for example, in the .run block of the application module. Note that with $routeProvider you define routes (configuration) and $route uses configuration-dependent methods.

There are three ways to define services: the simplest uses service , then you can also use factory and if you need complex configuration, you use provider AngularJS: Service versus provider vs factory

+7
source

As @elclanrs pointed out, there is no $ router that I know of. So I assume that you mean the difference between $ route and $ routeProvider

The $ route is used to deep link URLs to controllers and views. It tracks location addresses and tries to match it with existing paths. $ Route is configured (defined) using $ routeProvider.

Here is the official documentation of $ route , $ routeProvider

+2
source

Source: https://habr.com/ru/post/1493790/


All Articles