codelab: announce changes with LiveAnnouncer

This commit is contained in:
twerske
2021-04-19 12:19:15 -07:00
parent 685ba7add7
commit 4dd6f7f486
2 changed files with 7 additions and 2 deletions

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { Component, EventEmitter, OnInit, Output } from '@angular/core'; import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog'; import { MatDialogRef } from '@angular/material/dialog';
@@ -44,7 +45,8 @@ export class ColorPickerDialogComponent implements OnInit {
]; ];
// TODO: #11. Announce changes with LiveAnnouncer // TODO: #11. Announce changes with LiveAnnouncer
constructor(public dialogRef: MatDialogRef<ColorPickerDialogComponent>) { } constructor(public dialogRef: MatDialogRef<ColorPickerDialogComponent>,
private liveAnnouncer: LiveAnnouncer) { }
ngOnInit(): void { } ngOnInit(): void { }
@@ -54,6 +56,7 @@ export class ColorPickerDialogComponent implements OnInit {
} }
// TODO: #11. Announce changes with LiveAnnouncer // TODO: #11. Announce changes with LiveAnnouncer
this.liveAnnouncer.announce(`Select color: ${color}`);
this.dialogRef.close(); this.dialogRef.close();
} }

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { LiveAnnouncer } from '@angular/cdk/a11y';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
@Component({ @Component({
@@ -29,7 +30,7 @@ export class ShopComponent implements OnInit {
selectedFillings: string[] = []; selectedFillings: string[] = [];
// TODO: #11. Announce changes with LiveAnnouncer // TODO: #11. Announce changes with LiveAnnouncer
constructor() { } constructor(private liveAnnouncer: LiveAnnouncer) { }
ngOnInit(): void { } ngOnInit(): void { }
@@ -53,5 +54,6 @@ export class ShopComponent implements OnInit {
console.log(fakePurchase); console.log(fakePurchase);
// TODO: #11. Announce changes with LiveAnnouncer // TODO: #11. Announce changes with LiveAnnouncer
this.liveAnnouncer.announce(fakePurchase);
} }
} }