Skip to content

Commit

Permalink
codelab: announce changes with LiveAnnouncer
Browse files Browse the repository at this point in the history
  • Loading branch information
twerske committed May 11, 2022
1 parent 685ba7a commit 4dd6f7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';

Expand Down Expand Up @@ -44,7 +45,8 @@ export class ColorPickerDialogComponent implements OnInit {
];

// TODO: #11. Announce changes with LiveAnnouncer
constructor(public dialogRef: MatDialogRef<ColorPickerDialogComponent>) { }
constructor(public dialogRef: MatDialogRef<ColorPickerDialogComponent>,
private liveAnnouncer: LiveAnnouncer) { }

ngOnInit(): void { }

Expand All @@ -54,6 +56,7 @@ export class ColorPickerDialogComponent implements OnInit {
}

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

Expand Down
4 changes: 3 additions & 1 deletion src/app/shop/shop.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { Component, OnInit } from '@angular/core';

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

// TODO: #11. Announce changes with LiveAnnouncer
constructor() { }
constructor(private liveAnnouncer: LiveAnnouncer) { }

ngOnInit(): void { }

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

// TODO: #11. Announce changes with LiveAnnouncer
this.liveAnnouncer.announce(fakePurchase);
}
}

0 comments on commit 4dd6f7f

Please sign in to comment.