angular http: how to call images with custom headers?

前端 未结 5 2232
不思量自难忘°
不思量自难忘° 2020-12-09 03:28

In the html view, images are displayed like this:

 

element.image.url points to a

5条回答
  •  抹茶落季
    2020-12-09 04:15

    Consider the URL be http://foo.com/bar.png

    In your controller,

    angular.module('foo')
      .controller('fooCtrl', ['$sce',
        function($sce) {
          $scope.dataSrc = "http://foo.com/bar.png"
          $scope.src = $sce.trustAsResourceUrl($scope.dataSrc)
        }
      ])

    And in your view,

    .. seems to do the trick.

提交回复
热议问题