Force HTTP interceptor in dynamic ngSrc request

后端 未结 4 1088
一整个雨季
一整个雨季 2020-12-03 03:53

I\'ve created an AngularJS application that loads images from an OAuth secured backend. My OAuth library is configured by adding an extra interceptor to the Angular $h

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 04:11

    The ngSrc directive just controls the usual src attribute for an img, which makes the browser request the image just like any other image, not via Javascript, so I don't think this can be intercepted.

    However, what you could do, is write a new directive, save httpSrc. This then can fetch the image using a call to $http, and then create a data URI with the response using something like Using raw image data from ajax request for data URI (although I'm not sure of the browser support for it).

提交回复
热议问题