Search code examples
angularjsangularjs-directivex-http-method-override

How to override angular ngSrc directive to append request header?


I want to append a authentication token to the angular js ngSrc url request. So how can I pass this token with ngSrc directive?


Solution

  • Use http-src instead of ng-src and it will fetch images using the $http service - meaning Authorization headers added via interceptors will be present - then build a Blob and set the src to an objectURL.

    Reference:https://github.com/dougmoscrop/angular-img-http-src