Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
655 views
in Technique[技术] by (71.8m points)

typescript - Problem with using angular material-carousel slider with image

I'm tring to build carousel with images in angular.
I did it acoording to this link: https://therichpost.com/angular-9-material-carousel-slider/.
but it doesnt work.
the problem is that it shows only the first image.
This is the code:

home.component.html

   <mat-carousel
        timings="250ms ease-in"
        [autoplay]="true"
        interval="5000"
        color="accent"
        maxWidth="auto"
        proportion="25"
        slides="5"
        [loop]="true"
        [hideArrows]="false"
        [hideIndicators]="false"
        [useKeyboard]="true"
        [useMouseWheel]="false"
        orientation="ltr">
    
        <mat-carousel-slide
            #matCarouselSlide
            *ngFor="let slide of slides; let i = index"
            [image]="slide.image"
            overlayColor="#00000040"
            [hideOverlay]="false">
        </mat-carousel-slide>
    </mat-carousel>

home.component.ts

  slides = [
    {'image': 'https://image.freepik.com/free-photo/chalk-board-sketch-with-loudspeaker-phrase-we-need-volunteers_78790-1167.jpg'}, 
    {'image': 'https://image.freepik.com/free-photo/together-we-can-help-concept_23-2148733265.jpg'}, 
    {'image': 'https://image.freepik.com/free-photo/people-old-woman-young-hand-care-holding-healthcare-disabled-walking-with-assistance_36325-2363.jpg'},
    {'image': 'https://image.freepik.com/free-photo/pupils-reading-book-classroom_1150-3859.jpg'}, 
    {'image': 'https://image.freepik.com/free-photo/group-multiethnic-diverse-hands-raised_53876-64967.jpg'}];

Can you help me and find the mistake?
Thank you so much!!

question from:https://stackoverflow.com/questions/65904423/problem-with-using-angular-material-carousel-slider-with-image

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Checkout this working fiddle I created using above details and it works.

stackblitz


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...