1
1
import { FocusMonitor } from '@angular/cdk/a11y' ;
2
2
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' ;
4
4
import { FormBuilder , FormGroup } from '@angular/forms' ;
5
5
import { MatFormFieldControl } from '@angular/material/form-field' ;
6
6
import { Subject } from 'rxjs/Subject' ;
@@ -18,6 +18,11 @@ export class MyTel {
18
18
templateUrl : 'form-field-custom-control-example.html' ,
19
19
styleUrls : [ 'form-field-custom-control-example.css' ] ,
20
20
providers : [ { provide : MatFormFieldControl , useExisting : MyTelInput } ] ,
21
+ host : {
22
+ '[class.floating]' : 'shouldPlaceholderFloat' ,
23
+ '[id]' : 'id' ,
24
+ '[attr.aria-describedby]' : 'describedBy' ,
25
+ }
21
26
} )
22
27
export class MyTelInput implements MatFormFieldControl < MyTel > , OnDestroy {
23
28
static nextId = 0 ;
@@ -39,14 +44,13 @@ export class MyTelInput implements MatFormFieldControl<MyTel>, OnDestroy {
39
44
return ! n . area && ! n . exchange && ! n . subscriber ;
40
45
}
41
46
42
- @HostBinding ( 'class.floating' )
43
47
get shouldPlaceholderFloat ( ) {
44
48
return this . focused || ! this . empty ;
45
49
}
46
50
47
- @ HostBinding ( ) id = `my-tel-input-${ MyTelInput . nextId ++ } ` ;
51
+ id = `my-tel-input-${ MyTelInput . nextId ++ } ` ;
48
52
49
- @ HostBinding ( 'attr.aria-describedby' ) describedBy = '' ;
53
+ describedBy = '' ;
50
54
51
55
@Input ( )
52
56
get placeholder ( ) {
0 commit comments