Reputation:
Please forgive if this question is too silly or asked before I goggled a lot but I didn't get the right answer.
I'm new to Ember.js and I'm stuck with a problem I need to display my avatar pic in a image box like
<img src="~/Assets/Images/avatary.png" alt="avatar">
My question is How can I do the same using Ember.js
Upvotes: 2
Views: 1464
Reputation: 23322
You could create an image wrapper to have ember handle bindings and more for you. For example you could create something like this:
App.AvatarImage = Ember.View.extend({
attributeBindings: ['src', 'alt'],
src: '~/Assets/Images/avatary.png', // note that this path will not work at all if you serve your ember app from an webserver
alt: 'avatar',
tagName: 'img'
});
And then use it in your templates like so:
{{view App.AvatarImage}}
Here a working jsbin
Hope it helps
Upvotes: 3