How to prevent ng-src to load image before data arrives?

后端 未结 4 530
暖寄归人
暖寄归人 2021-01-31 09:04

HTML:

 \"{{album.title}}\"

While running the app, it

4条回答
  •  悲哀的现实
    2021-01-31 09:58

    I believe ng-src waits for it's value to change to apply a src value to the element. Did you try changing

    to

    ?

    EDIT - revised answer

    As ng-src waits for the information in {{}} to change, it has no way of knowing if EVERY aspect of it is ready. I can think of two possible solutions:

    a) Make a url_when_ready() function, that takes strings as arguments and concatenates them, only returning a value if all of the strings are defined. Then do

    ng-src="{{url_when_ready([plugins.filesPath.album_images.image, album.cover_image])}}

    b) create a model $scope.album.cover_image_full that updates when $scope.album.cover_image is ready, and use that as the ng-src value

提交回复
热议问题