Search code examples
angularjsng-file-upload

ngf-src not working with {{vm.detail.id}}


I want to display the image preview or the user's avatar when the page is loaded but the ngf-src is not working as I expected:

<img id="avatar" class="ui centered image" ngf-src="avatar || 'http://localhost:8000/img/user_avatar/{{vm.detail.id}}.jpg'">

somehow I can not get the picture from the server. It showed on the HTML like this:

<img src="http://localhost:8000/img/user_avatar/.jpg" id="avatar" class="ui centered image" ngf-src="avatar || 'http://localhost:8000/img/user_avatar/5.jpg'">

Could anyone help please!


Solution

  • I found a solution for my question, I posted it here in case if it could help someone else:

    <img id="avatar" class="ui centered image" ngf-src="avatar || vm.avatarURL">
    

    the vm.avatarURL is from the controller