ionic image gallery

https://ionicacademy.com/ionic-image-gallery-responsive/



<ion-header>
  <ion-navbar>
    <ion-title>
      Image Gallery
    </ion-title>
  </ion-navbar>
</ion-header>
 
<ion-content padding>
  <ion-segment [(ngModel)]="galleryType" color="primary">
    <ion-segment-button value="regular">
      Regular
    </ion-segment-button>
    <ion-segment-button value="pinterest">
      Pinterest
    </ion-segment-button>
  </ion-segment>
 
  <div [ngSwitch]="galleryType">
    <!-- Responsive Layout with Ion Grid-->
    <ion-grid *ngSwitchCase="'regular'">
      <ion-row>
        <ion-col col-6 col-md-4 col-xl-3 *ngFor="let image of [1,2,3,4,5,6,7,8,9,10,11]">
          <div class="image-container" [style.background-image]="'url(assets/img/' + image + '.jpg)'"></div>
        </ion-col>
      </ion-row>
    </ion-grid>
 
 
    <!-- More Pinterest floating gallery style -->
 
  </div>
</ion-content>


css


page-home {
    .image-container {
        min-height: 200px;
        background-size: cover;
    }
}

ts file

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
 
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  galleryType = 'regular';
  constructor(public navCtrl: NavController) { }
}

Comments

Popular posts from this blog

Your app currently targets API level 27 and must target at least API level 28 to ensure it is built on the latest APIs optimized for security and performance. Change your app's target API level to at least 28

ionic project creation

change root user in ubuntu