[solved]Array index doesnt work


#1
{{#if getRefreshPreview}}
      {{#if $eq coverImg pictures.[slot]}}
            {{> uploadFormCrop slot=slot pictures=pictures projectId=_id }}
            {{> deleteImageButton slot=slot pictures=pictures projectId=_id }}
            {{> titleImage}}
      {{else}}
            {{slot}}
            {{pictures}}
            {{pictures.[0]}}
            {{pictures.[slot]}}
            {{> uploadFormCrop slot=slot pictures=pictures projectId=_id }}
            {{> setTitleImageButton slot=slot pictures=pictures projectId=_id }}
            {{> deleteImageButton slot=slot pictures=pictures projectId=_id }}
            {{> galleryPreviewEdit result}}
      {{/if}}
{{else}}
      {{> uploadFormCrop slot=slot pictures=pictures projectId=_id }}
      {{> deleteImageButton slot=slot pictures=pictures projectId=_id }}
      {{> titleImage}}
{{/if}}

I have an Array with 5 picture ids.

if i print {{slot}} im getting the current slot like 0,1,2,3,4,5…
at {{pictures}} im getting the whole array
at {{pictures.[0]}} im getting the picture id at slot 0
but {{pictures.[slot]}} doesnt work :frowning:


#2

Yes yes, I had this problem before. Blaze is not that smart!

Try creating a helper {{ picture slot }}

helpers({
    picture(slot) {
         return this.data.pictures[slot];
    }
})

Good luck!


#3

thx =) its working :slight_smile: