Quantcast
Viewing all articles
Browse latest Browse all 4827

How to get item from model array in helper

@john123 wrote:

Hello, I have a model lets say it property(estate) and it has relation oneToMany for model Images, so at the listing screen I need only one image for preview and I’m trying to pass images into helper get-cover and return first object from the array.

import { helper } from ‘@ember/component/helper’;

export function getCover([images]) { console.log(images.get(1)) return images.firstObject.image;

}

export default helper(getCover);

image property contents url on image, but it doesnt work

But if I’m doing with {{#each this.property.images as |image|}} in template everything is ok and it shows 3 images but how can I get only one for preview?

thank you in advance

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4827

Trending Articles