gbrlsnchs / material2-carousel

A carousel component for Angular using Material
https://gsr.dev/material2-carousel
MIT License
85 stars 114 forks source link

How to overrides icons? #47

Closed Khvesiuk closed 4 years ago

Khvesiuk commented 4 years ago

Expected something like this? But not...

<ng-template svgIconOverrides="arrowBack">
    <mat-icon svgIcon="custom_back"></mat-icon>
  </ng-template>
  <ng-template svgIconOverrides="arrowForward">
    <mat-icon svgIcon="custom_forward"></mat-icon>
  </ng-template>
gbrlsnchs commented 4 years ago

You can use svgIconOverrides to override default icons.

Khvesiuk commented 4 years ago

example?

Khvesiuk commented 4 years ago

okay, here is my working example: app.components.ts

import { MatIconRegistry } from '@angular/material';

constructor(iconRegistry: MatIconRegistry) {
iconRegistry
.addSvgIcon('custom-back', sanitizer.bypassSecurityTrustResourceUrl('../assets/arrow_back.svg'))
.addSvgIcon('custom-forward', sanitizer.bypassSecurityTrustResourceUrl('../assets/arrow_forward.svg'))
}

carousel.component.ts

export class CarouselComponent {
 iconOverrides: SvgIconOverrides = {
    arrowForward: 'custom-forward',
    arrowBack: 'custom-back'
  }
}

carousel.component.html

<mat-carousel  
  [hideIndicators]="false"
  [svgIconOverrides]="iconOverrides">
   <mat-carousel-slide></mat-carousel-slide>
</mat-carousel>
gbrlsnchs commented 4 years ago

Thanks for your patience, @Khvesiuk, as I could not provide an example. I'll try to add your example to the README.