Skip to content

Commit

Permalink
fix(autofill): use static queries to read values used in ngOnInit (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
pkozlowski-opensource authored and andrewseguin committed Mar 25, 2019
1 parent a1e1e70 commit cb0b025
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {AutofillMonitor} from '@angular/cdk/text-field';
import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {AfterViewInit, Component, ElementRef, OnDestroy, ViewChild} from '@angular/core';

/** @title Monitoring autofill state with AutofillMonitor */
@Component({
selector: 'text-field-autofill-monitor-example',
templateUrl: './text-field-autofill-monitor-example.html',
styleUrls: ['./text-field-autofill-monitor-example.css'],
})
export class TextFieldAutofillMonitorExample implements OnDestroy, OnInit {
export class TextFieldAutofillMonitorExample implements AfterViewInit, OnDestroy {
@ViewChild('first', {read: ElementRef}) firstName: ElementRef<HTMLElement>;
@ViewChild('last', {read: ElementRef}) lastName: ElementRef<HTMLElement>;
firstNameAutofilled: boolean;
lastNameAutofilled: boolean;

constructor(private autofill: AutofillMonitor) {}

ngOnInit() {
ngAfterViewInit() {
this.autofill.monitor(this.firstName)
.subscribe(e => this.firstNameAutofilled = e.isAutofilled);
this.autofill.monitor(this.lastName)
Expand Down

0 comments on commit cb0b025

Please sign in to comment.