src/lib/src/component/md/md-date-format.component.ts
providers |
{ provide: NG_VALUE_ACCESSOR, useExisting: , multi: }
{ provide: NG_VALIDATORS, useExisting: , multi: }
|
selector | md-date-format |
templateUrl | ./md-date-format.component.html |
Methods |
Inputs |
constructor(dateAdapter: DateAdapter
|
||||||||
Parameters :
|
locale
|
Default value: |
ngOnInit |
ngOnInit()
|
Returns :
void
|
import { Component, Input, forwardRef, OnInit } from '@angular/core';
import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
import { DateAdapter, NativeDateAdapter } from '@angular/material';
/* Own modules */
import { BaseDateFormatComponent } from '../base-date-format.component';
@Component({
selector: 'md-date-format',
templateUrl: './md-date-format.component.html',
providers: [
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => MdDateFormatComponent), multi: true },
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => MdDateFormatComponent), multi: true }
]
})
export class MdDateFormatComponent extends BaseDateFormatComponent implements OnInit {
@Input() locale = 'pt-BR';
constructor(private dateAdapter: DateAdapter<NativeDateAdapter>) {
super();
}
ngOnInit() {
super.ngOnInit();
this.dateAdapter.setLocale(this.locale);
}
}
<md-form-field>
<input mdInput
type='tel'
[ngClass]='cssclass'
[textMask]='{mask:dateMask}'
[placeholder]='placeholder'
[readonly]='readonly'
[name]='inputname'
[(ngModel)]='_date'
[min]="minDate"
[max]="maxDate"
(focus)='focusEvent($event)'
(keyup)='keyUpEvent($event)'
(keydown)='keyDownEvent($event)'
[disabled]='isDisabled()'
/>
</md-form-field>