Skip to content

Commit 3f0142b

Browse files
mmalerbakara
authored andcommitted
chore: don't use HostBinding in example (#7540)
1 parent adf9b5b commit 3f0142b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/material-examples/form-field-custom-control/form-field-custom-control-example.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {FocusMonitor} from '@angular/cdk/a11y';
22
import {coerceBooleanProperty} from '@angular/cdk/coercion';
3-
import {Component, ElementRef, HostBinding, Input, OnDestroy, Renderer2} from '@angular/core';
3+
import {Component, ElementRef, Input, OnDestroy, Renderer2} from '@angular/core';
44
import {FormBuilder, FormGroup} from '@angular/forms';
55
import {MatFormFieldControl} from '@angular/material/form-field';
66
import {Subject} from 'rxjs/Subject';
@@ -18,6 +18,11 @@ export class MyTel {
1818
templateUrl: 'form-field-custom-control-example.html',
1919
styleUrls: ['form-field-custom-control-example.css'],
2020
providers: [{provide: MatFormFieldControl, useExisting: MyTelInput}],
21+
host: {
22+
'[class.floating]': 'shouldPlaceholderFloat',
23+
'[id]': 'id',
24+
'[attr.aria-describedby]': 'describedBy',
25+
}
2126
})
2227
export class MyTelInput implements MatFormFieldControl<MyTel>, OnDestroy {
2328
static nextId = 0;
@@ -39,14 +44,13 @@ export class MyTelInput implements MatFormFieldControl<MyTel>, OnDestroy {
3944
return !n.area && !n.exchange && !n.subscriber;
4045
}
4146

42-
@HostBinding('class.floating')
4347
get shouldPlaceholderFloat() {
4448
return this.focused || !this.empty;
4549
}
4650

47-
@HostBinding() id = `my-tel-input-${MyTelInput.nextId++}`;
51+
id = `my-tel-input-${MyTelInput.nextId++}`;
4852

49-
@HostBinding('attr.aria-describedby') describedBy = '';
53+
describedBy = '';
5054

5155
@Input()
5256
get placeholder() {

0 commit comments

Comments
 (0)