search

Home  >  Q&A  >  body text

angular.js - How to adjust the background interface and synchronize the returned data to the service on the scope? ~

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~

PHPzPHPz2858 days ago910

reply all(2)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-15 17:14:07

    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...

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-15 17:14:07

    The service layer is only used to request interfaces, and callbacks and data operations are done in the controller

    reply
    0
  • Cancelreply