Skip to content

Instantly share code, notes, and snippets.

@MurhafSousli
Last active December 9, 2023 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MurhafSousli/bbe41040f3dabd8a2fd918a9e3602183 to your computer and use it in GitHub Desktop.
Save MurhafSousli/bbe41040f3dabd8a2fd918a9e3602183 to your computer and use it in GitHub Desktop.
Proposal: Carousel usage
<carousel [data]="items">
<carousel-thumbs></carousel-thumbs>
<div *carouselItem="let item">
<img src="item.src">
</div>
<div *carouselThumb="let item">
<img src="item.thumb">
</div>
</carousel>
<!-- πŸ‘Ž Cannot add items individually, must have a custom for loop -->
<!-- πŸ‘Ž No type checking / autocompletion -->
<!-- πŸ‘ items object is passed using an input -->
<!-- πŸ‘ No need for ng-container -->
<carousel>
<carousel-thumbs></carousel-thumbs>
<ng-container *carouselFor="let item of items">
<div carouselItem>
<img src="item.src">
</div>
<div carouselThumb>
<img src="item.thumb">
</div>
</ng-container>
</carousel>
<!-- πŸ‘Ž Cannot add items individually, must have a custom for loop -->
<!-- πŸ‘ Type checking / autocompletion can be accomplished -->
<!-- πŸ‘Ž Has to be used on ng-container if thumb template needed -->
<!-- πŸ‘ items object is passed using an input -->
<carousel>
<carousel-thumbs></carousel-thumbs>
<ng-container *ngFor="let item of items">
<div *carouselItem>
<img src="item.src">
</div>
<div *carouselThumb>
<img src="item.thumb">
</div>
</ng-container>
</carousel>
<!-- πŸ‘ Can add items individually without ngFor -->
<!-- πŸ‘ Type checking / autocompletion is available -->
<!-- πŸ‘Ž Traditional ngFor -->
<!-- πŸ‘Ž Must to be used on ng-container -->
<!-- ❔ Use ContentChildren stream to project items -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment