This article will provide an Angular Material carousel in angular 11 material. if you have a question about the angular 11 material carousel slider example then I will give a simple example with a solution. In this article, we will implement Angular Material carousel angular 10/11. Here you will learn how to add angular 11 material design carousel example step by step.
How To Add Angular Material Carousel Angular 10/11
Install npm Package
ng add @angular/material
npm install @ngmodule/material-carousel
Import MatCarouselModule
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; //--------- Important
import { MatCarouselModule } from '@ngmodule/material-carousel'; // ---------- Important
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule, // ---------- Important
FormsModule,
ReactiveFormsModule,
MatCarouselModule.forRoot() // ---------- Important
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Update Ts File
import { Component } from '@angular/core';
import { MatCarousel, MatCarouselComponent } from '@ngmodule/material-carousel'; // -------- important
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
slides = [
{'image': 'https://picsum.photos/seed/picsum/1200/300'},
{'image': 'https://picsum.photos/seed/picsum/1200/300'},
{'image': 'https://picsum.photos/seed/picsum/1200/300'},
{'image': 'https://picsum.photos/seed/picsum/1200/300'},
{'image': 'https://picsum.photos/seed/picsum/1200/300'}
];
}
Original Source: https://www.phpcodingstuff.com/blog/how-to-add-angular-material-carousel-angular.html
Top comments (0)