Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom template from scratch #125

Closed
ayazhussein opened this issue Jul 4, 2018 · 1 comment
Closed

Allow custom template from scratch #125

ayazhussein opened this issue Jul 4, 2018 · 1 comment

Comments

@ayazhussein
Copy link

Hello,
Since 3.0.0, is there a way to pass an observable as src image since I have to generate signedUrl from the API, before we could've implement custom image component and it worked.

Open to suggestions :D

@MurhafSousli
Copy link
Owner

MurhafSousli commented Jul 4, 2018

@ayazhussein It is possible in 3.0.1

this.items = [
   new CustomItem({ 
      src: of(item.srcUrl), 
      thumb: item.previewUrl
   })
];

export class CustomItem implements GalleryItem {

  readonly type = 'custom-item';
  readonly data: any;

  constructor(data: any) {
    this.data = data;
  }
}
<gallery [items]="items" [itemTemplate]="itemTemplate"></gallery>


<ng-template #itemTemplate
             let-index="index"
             let-type="type"
             let-data="data"
             let-currIndex="currIndex">
  
  <!-- Use custom template or component -->
  <my-custom-gallery-item [src]="data.src"></my-custom-gallery-item>

</ng-template>

Check this stackbltiz

@MurhafSousli MurhafSousli changed the title image Src as observable Allow custom template from scratch Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants