The question about angular

recently in learning angular, it should be said that angular2, because he learned vue, before coming into contact with angular, always compares the relationship between the two in the learning process, contrasts with each other to learn and use, using two frameworks to achieve some small demo, for example, todomvc .
but I was confused when I learned about the service. How should I understand the service of angular, that is, service?
I am learning the channel of anguar, that is, pipe. What I am comparing is that the instructions of vue"s filter,angular are similar to those of vue, but the configuration is rather strange. I can only describe it this way. I have no idea what the nature of angular"s configuration of some services is.
can"t find a reference in vue at all.
Xiaobai, don"t spray, Wanwang God will solve the confusion


The service in

AngularJS actually provides a way to extract common class libraries, such as some utility class methods. Our traditional practice is to write a utility class, populate the relevant tool methods into utility, and finally put the utility class into a global variable, so that utility methods can be called anywhere. If you use AngularJS's service, you create a utility service according to his rules, and then you can invoke methods in utility anywhere through dependency injection. There are three ways for Angular to create services: providers,factory,service,. You can see the difference between provider, factory and service in AngularJS

author: Xu Haifeng
link:

service is an encapsulation of the model layer, and the extraction of common class libraries is usually used to manage data and requests.


is mainly to facilitate the management of services (classes). You can learn about the service, of IOC (dependency injection)


angular.
one is that injectable service, is decorated with @ Injectable, which uses the
idea of dependency injection. You can inject other service, into component, such as passing values to each other as a bridge between two component, or as an application-level service, such as authentication, dirty check, and so on.
the other is non-injectable service, that is, it is not decorated with @ Injectable.
then its function is very simple, that is, it is an auxiliary class.


you can uniformly manage data requests in service

Menu