1
votes

The first image is what I am getting currently and second is what I actually want

First:-

enter image description here

Second:-

enter image description here

<mat-card class="carousel-data">
    <mat-grid-list cols="2" rowHeight="30px" class="carousel-data" *ngFor="let data of resource let i = index;" (click)="showdata()" >

        <mat-grid-tile>     
           <img class="m-t-0 m-b-0 "[src]="data.img" alt="" width="24">
            <div class="prof-left" style="margin-left: 10px;">
                <p class="m-t-0 m-b-0 bank-name">{{ data.bank_name}}</p>
                <p class="m-t-0 m-b-0 bank-account">{{ data.account_number }}</p>
            </div>
        </mat-grid-tile>
        <mat-grid-tile>
            <div class="prof-right">
                <p class="m-t-0 m-b-0 total-bal">Total Bal</p>
                <p class="m-t-0 m-b-0 total-amount">{{ data.amount }}</p>
            </div>
        </mat-grid-tile>
    </mat-grid-list>
</mat-card>

enter image description here

3
Maybe you can try with what Angular Material Documentation calls an Stepper: material.angular.io/components/stepper/overview - aaron aaron aaron

3 Answers

0
votes

You can use OWl Carousel for that something like

 <div class="owl-carousel owl-theme">
       <div class="item" *ngFor="let data of resource let i = index;">
 <mat-grid-list cols="2" rowHeight="30px" class="carousel-data"  (click)="showdata()" >

        <mat-grid-tile>     
           <img class="m-t-0 m-b-0 "[src]="data.img" alt="" width="24">
            <div class="prof-left" style="margin-left: 10px;">
                <p class="m-t-0 m-b-0 bank-name">{{ data.bank_name}}</p>
                <p class="m-t-0 m-b-0 bank-account">{{ data.account_number }}</p>
            </div>
        </mat-grid-tile>
        <mat-grid-tile>
            <div class="prof-right">
                <p class="m-t-0 m-b-0 total-bal">Total Bal</p>
                <p class="m-t-0 m-b-0 total-amount">{{ data.amount }}</p>
            </div>
        </mat-grid-tile>
    </mat-grid-list>
    </div>
    </div>

in your componenet

ngAfterViewInit(){
    $('.owl-carousel').owlCarousel({
    loop:true,
    margin:10,
    nav:true,
    responsive:{
        0:{
            items:1
        },
        600:{
            items:3
        },
        1000:{
            items:5
        }
    }
   })
  }

Check this demo to see how to use with angular

note you have to include jquery and owl carousel file to make it work

Or you can use ngx-owl-carousel

0
votes

Run yarn add ngx-owl-carousel-o or npm install ngx-owl-carousel-o or ng add ngx-owl-carousel-o.

Add styles (one of these variants). src/styles.sass or src/styles.scss:

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel';
@import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';

Import RoutingModule and Routes into AppModule unless they are imported.

Import BrowserAnimationsModule into AppModule unless it is imported.

Import CarouselModule into a module which declares a component intended to have a carousel.

import { CarouselModule } from 'ngx-owl-carousel-o';
@NgModule({
  imports: [ CarouselModule ],
  declarations: [ CarouselHolderComponent ]
})
export class SomeModule { }

Add to needed component customOptions or named in different way object with options for the carousel:

import { OwlOptions } from 'ngx-owl-carousel-o';
@Component({
  selector: '....',
  templateUrl: 'carousel-holder.component.html'
})
export class CarouselHolderComponent {
  customOptions: OwlOptions = {
    loop: true,
    mouseDrag: false,
    touchDrag: false,
    pullDrag: false,
    dots: false,
    navSpeed: 700,
    navText: ['', ''],
    responsive: {
      0: {
        items: 1
      },
      400: {
        items: 2
      },
      740: {
        items: 3
      },
      940: {
        items: 4
      }
    },
    nav: true
  }
}
Add html-markup to the template of the component (in this case, add it to carousel-holder.component.html):

  <div>Some tags before</div>
    <owl-carousel-o [options]="customOptions">
    <ng-template carouselSlide>Slide 1</ng-template>  
    <ng-template carouselSlide>Slide 2</ng-template>  
    <ng-template carouselSlide>Slide 3</ng-template>  
  </owl-carousel-o>
  <div>Some tags after</div>

or

<div>Some tags before</div>
    <owl-carousel-o [options]="customOptions">

    <ng-container *ngFor="let slide of slidesStore">
      <ng-template carouselSlide [id]="slide.id">
        <img [src]="slide.src" [alt]="slide.alt" [title]="slide.title">
      </ng-template>
    </ng-container>

  </owl-carousel-o>
  <div>Some tags after</div>

please follow this link

0
votes
            **Steps Needs to follow to achieve Carousel:-**

1. ng new owl-carousel
2. npm install ngx-owl-carousel owl.carousel jquery --save
3. Add library files in angular.json

            "styles": [
            "src/styles.css",
            "./node_modules/owl.carousel/dist/assets/owl.carousel.min.css",
            "./node_modules/owl.carousel/dist/assets/owl.theme.default.min.css"
            ],
            "scripts": ["./node_modules/jquery/dist/jquery.min.js",
            "./node_modules/owl.carousel/dist/owl.carousel.min.js"]
            },
            <br><br>

           **4.** `Update app.module.ts file`<br>
                import { OwlModule } from 'ngx-owl-carousel';
                // Add OwlModule to imports at below section
                imports: [BrowserModule, OwlModule],
                <br><br>

5. Update app.component.ts file
mySlideImages = ['../assets/images/image1.jpg','../assets/images/image2.jpeg','../assets/images/image3.jpg'];
mySlideOptions={items: 1, dots: true, nav: true};

6. Update app.component.html file

For details you can follow this link Carousel