Skip to content
This repository was archived by the owner on Feb 15, 2026. It is now read-only.

Commit 4dd6f7f

Browse files
committed
codelab: announce changes with LiveAnnouncer
1 parent 685ba7a commit 4dd6f7f

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/app/shop/color-picker/color-picker-dialog/color-picker-dialog.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
import { LiveAnnouncer } from '@angular/cdk/a11y';
1617
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
1718
import { MatDialogRef } from '@angular/material/dialog';
1819

@@ -44,7 +45,8 @@ export class ColorPickerDialogComponent implements OnInit {
4445
];
4546

4647
// TODO: #11. Announce changes with LiveAnnouncer
47-
constructor(public dialogRef: MatDialogRef<ColorPickerDialogComponent>) { }
48+
constructor(public dialogRef: MatDialogRef<ColorPickerDialogComponent>,
49+
private liveAnnouncer: LiveAnnouncer) { }
4850

4951
ngOnInit(): void { }
5052

@@ -54,6 +56,7 @@ export class ColorPickerDialogComponent implements OnInit {
5456
}
5557

5658
// TODO: #11. Announce changes with LiveAnnouncer
59+
this.liveAnnouncer.announce(`Select color: ${color}`);
5760
this.dialogRef.close();
5861
}
5962

src/app/shop/shop.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
import { LiveAnnouncer } from '@angular/cdk/a11y';
1617
import { Component, OnInit } from '@angular/core';
1718

1819
@Component({
@@ -29,7 +30,7 @@ export class ShopComponent implements OnInit {
2930
selectedFillings: string[] = [];
3031

3132
// TODO: #11. Announce changes with LiveAnnouncer
32-
constructor() { }
33+
constructor(private liveAnnouncer: LiveAnnouncer) { }
3334

3435
ngOnInit(): void { }
3536

@@ -53,5 +54,6 @@ export class ShopComponent implements OnInit {
5354
console.log(fakePurchase);
5455

5556
// TODO: #11. Announce changes with LiveAnnouncer
57+
this.liveAnnouncer.announce(fakePurchase);
5658
}
5759
}

0 commit comments

Comments
 (0)