Bug
Im using:
this.myForm = this._fb.group({
...
estimatedApplicationDate: [
{ value: this.data.applicationDate, disabled: true },
[Validators.required]
]
});
and template:
<input mdInput formControlName="estimatedApplicationDate"
[mdDatepicker]="estimatedApplicationDateDatepicker"
placeholder="Date d鈥檃pplication estim茅e" required
(click)="estimatedApplicationDateDatepicker.open()">
<button mdSuffix [mdDatepickerToggle]="estimatedApplicationDateDatepicker"></button>
<md-datepicker #estimatedApplicationDateDatepicker></md-datepicker>
=> The input is disabled as specified, but I can still open the datepicker panel
The datepicker icon shouldn't be clickable
Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: https://goo.gl/DlHd6U (template not working, lots of 404)
Consistency i guess
Work-around:
<button mdSuffix
[mdDatepickerToggle]="myForm.get('estimatedApplicationDate').disabled? null : estimatedApplicationDateDatepicker">
</button>
I hope this is clear enough..
Thanks!
Have you tried disabling the md-datepicker itself?
<md-datepicker #estimatedApplicationDateDatepicker
[disabled]="myForm.get('estimatedApplicationDate').disabled"></md-datepicker>
You can also just disable the button
<button mdSuffix [disabled]="myForm.get('estimatedApplicationDate').disabled"
[mdDatepickerToggle]="estimatedApplicationDateDatepicker">
</button>
I feel like the button shouldn't be coupled to the form control, but could maybe understand the datepicker doing so.
Hi, thanks for the replies
@julianobrasil : Your solution throw an error for me:
Can't bind to 'disabled' since it isn't a known property of 'md-datepicker'.
@willshowell : It works well! and actually cleaner than my workaround
I also agree, on the one hand it make more sense they shouldn't be coupled, but on the other hand it creates inconsistency when disabling at the FormControl level...
There might be a problem with the docs or the component. ASAP I'll try it in a plunk.
Edited: maybe it's just decoupled as @willshowell suggested. But just throwing an error when you try to open It by clicking on the mdDatepickerToggle is strange.
Looking quickly at the code, I can tell there _is_ a disabled property. I haven't figured out yet the reason why it apparently doesn't work as I expected,
@julianobrasil it's new (https://github.com/angular/material2/pull/5305). Here's that same file at beta.8
https://github.com/angular/material2/blob/2.0.0-beta.8/src/lib/datepicker/datepicker.ts
Oh, now it makes sense. 馃樃
This has been fixed, just hasn't made it into a release yet
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
You can also just disable the button
I feel like the button shouldn't be coupled to the form control, but could maybe understand the datepicker doing so.