In the layout there are 2 absolutely identical templates for displaying an array, the only difference is in the name (they are also in the script). It is planned to make some more similar templates for storing data of new arrays. Is it possible to make the template in the singular in the layout, and the name of the array would dynamically change depending on the condition of the display of the array (with the help of switch / case unless ... maybe you have some other ideas to implement this
The display of one or another array will be when you click on the button with the name of the array. If one array is displayed, the second and the rest are hidden.
get allMovies(): Array<IMovie> { return this.movies.filter((m) => { const search = this.search.toLowerCase(); const film = m.film.toLowerCase(); return !m.seen && m.year <= +this.rangeYear && film.includes(search); }); } get seenMovies(): Array<IMovie> { return this.movies.filter((n) => { const search = this.search.toLowerCase(); const film = n.film.toLowerCase(); return n.seen && n.year <= +this.rangeYear && film.includes(search); }); }
<div class="movieApp"> <h1 >Все фильмы</h1> <div class="movieApp__movieList"> <div *ngFor="let film of allMovies"> <app-movie-card [movie]="film" (onOpenModal)="showMoreInformation($event)"></app-movie-card> </div> </div> <h1>Просмотренные</h1> <div class="movieApp__movieList"> <div *ngFor="let film of seenMovies"> <app-movie-card [movie]="film" (onOpenModal)="showMoreInformation($event)"></app-movie-card> </div> </div> </div>