Skip to content

Instantly share code, notes, and snippets.

@twerske
Created June 1, 2021 20:26
Show Gist options
  • Save twerske/60d7c1001fc70aadcdc592f61839a7b4 to your computer and use it in GitHub Desktop.
Save twerske/60d7c1001fc70aadcdc592f61839a7b4 to your computer and use it in GitHub Desktop.
Announce changes with LiveAnnouncer
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { Component } from '@angular/core';
@Component(...)
export class ColorPickerDialogComponent {
color = '#fff';
public defaultColors: string[] = [...];
constructor(private liveAnnouncer: LiveAnnouncer) { }
public changeColor(color: string): void {
this.liveAnnouncer.announce(`Select color: ${color}`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment