search

Home  >  Q&A  >  body text

angular.js - How to encapsulate upload in angularjs

Currently my method of uploading images is written separately. Here is an example, the following code:

Now I want to merge this upload into a method, write it in a public method, and call it directly in the controller,

However, the current problem is that each url and data take the interface address and current parameters of the current service. How do I merge the code and call it?

Please let me know, thank you~

黄舟黄舟2824 days ago509

reply all(1)I'll reply

  • 漂亮男人

    漂亮男人2017-05-15 17:11:10

    Just an idea, write a service, inject the upload plug-in dependency, and inside it is your $upload.upload method, which returns the formatted data.
    In other places, you only need to call this service and pass the current URL as a parameter

    reply
    0
  • Cancelreply