I think you want to ask about the role of Provider. $provide and $compileProvider in your example are all angular’s internal Providers. If you are smart, you have already seen that the call ofProvideris in the config. Then you also guessed that the Provider is the configuration of the current application. Directive, factory and other modules can be reused in multiple projects, but the environment of each project is different. Calling Provider can configure the environment of the current project. For example, when configuring routing, routeProvider is called in config to configure the routing of the project. Each project is different; httpProvider configures the behavior and return content of $http, locationProvider configures whether routing uses #, and so on. Custom providers only need to inject (provider name) Provider into the config to call the provider's method. By the way, the integrated provider also has a delegate method. If the current project's service requires special functions, it can be added through this, and it will not affect the original service.
I think you want to ask about the role of Provider.
$provide and $compileProvider in your example are all angular’s internal Providers.
If you are smart, you have already seen that the call of
Provider
is in the config. Then you also guessed that the Provider is the configuration of the current application.Directive, factory and other modules can be reused in multiple projects, but the environment of each project is different. Calling Provider can configure the environment of the current project.
For example, when configuring routing, routeProvider is called in config to configure the routing of the project. Each project is different; httpProvider configures the behavior and return content of $http, locationProvider configures whether routing uses #, and so on.
Custom providers only need to inject (provider name) Provider into the config to call the provider's method.
By the way, the integrated provider also has a delegate method. If the current project's service requires special functions, it can be added through this, and it will not affect the original service.