text-field-autofill-monitor-example.ts (material2-7.3.5) | : | text-field-autofill-monitor-example.ts (material2-7.3.6) | ||
---|---|---|---|---|
import {AutofillMonitor} from '@angular/cdk/text-field'; | import {AutofillMonitor} from '@angular/cdk/text-field'; | |||
import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core '; | import {AfterViewInit, Component, ElementRef, OnDestroy, ViewChild} from '@angul ar/core'; | |||
/** @title Monitoring autofill state with AutofillMonitor */ | /** @title Monitoring autofill state with AutofillMonitor */ | |||
@Component({ | @Component({ | |||
selector: 'text-field-autofill-monitor-example', | selector: 'text-field-autofill-monitor-example', | |||
templateUrl: './text-field-autofill-monitor-example.html', | templateUrl: './text-field-autofill-monitor-example.html', | |||
styleUrls: ['./text-field-autofill-monitor-example.css'], | 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('first', {read: ElementRef}) firstName: ElementRef<HTMLElement>; | |||
@ViewChild('last', {read: ElementRef}) lastName: ElementRef<HTMLElement>; | @ViewChild('last', {read: ElementRef}) lastName: ElementRef<HTMLElement>; | |||
firstNameAutofilled: boolean; | firstNameAutofilled: boolean; | |||
lastNameAutofilled: boolean; | lastNameAutofilled: boolean; | |||
constructor(private autofill: AutofillMonitor) {} | constructor(private autofill: AutofillMonitor) {} | |||
ngOnInit() { | ngAfterViewInit() { | |||
this.autofill.monitor(this.firstName) | this.autofill.monitor(this.firstName) | |||
.subscribe(e => this.firstNameAutofilled = e.isAutofilled); | .subscribe(e => this.firstNameAutofilled = e.isAutofilled); | |||
this.autofill.monitor(this.lastName) | this.autofill.monitor(this.lastName) | |||
.subscribe(e => this.lastNameAutofilled = e.isAutofilled); | .subscribe(e => this.lastNameAutofilled = e.isAutofilled); | |||
} | } | |||
ngOnDestroy() { | ngOnDestroy() { | |||
this.autofill.stopMonitoring(this.firstName); | this.autofill.stopMonitoring(this.firstName); | |||
this.autofill.stopMonitoring(this.lastName); | this.autofill.stopMonitoring(this.lastName); | |||
} | } | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added |