The interface can only be adjusted once. This makes it easy to use the service singleton feature. However, how to synchronize it to the scope? Define a method to return data. But the acquisition is asynchronous. When the method is called, the data may not be obtained. There is another problem. The first method is to pass the scope parameter into the service and update the scope asynchronously. But it seems that this is not recommended... Looking for a solution~
I can understand that you need to synchronize, that is, wait for the data to be obtained before calling the method
angular’s promise should be what you want
Post an article at the address:
/a/11...
The service layer is only used to request interfaces, and callbacks and data operations are done in the controller