Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set min property dynamically #269

Closed
dgroh opened this issue Oct 24, 2017 · 11 comments
Closed

Set min property dynamically #269

dgroh opened this issue Oct 24, 2017 · 11 comments
Assignees

Comments

@dgroh
Copy link

dgroh commented Oct 24, 2017

How do I set the min property dynamically?

I have a Date from and a Date to - The min of Date to must be the selected value of Date from I tried to achieve this by setting the component.config.min but nothing happens.

This stackblitz demonstrates this: Change min date dynamically

@vlio20
Copy link
Owner

vlio20 commented Oct 25, 2017

In order to change the configuration (and min is part of it) you need to pass a new reference to this.dateToDp.config:

    this.filterForm.get("dateFrom").valueChanges.subscribe(value => {
      console.log(this.dateToDp);
      this.dateToDp.config = {
        min: value,
        ...this.dateToDp
      };
    });
  }

here is a working stackblitz: https://stackblitz.com/edit/angular-3h4a7c

@dgroh
Copy link
Author

dgroh commented Oct 25, 2017

The rule of showing the min date when the picker opens should be applied, too. Means, the picker should start from the min date, what is not happening when changing the configuration.

@miyolou
Copy link

miyolou commented Oct 25, 2017

You can bind the value changes from 'Date from' to the displayDate attr on the 'Date to' input element.

@dgroh
Copy link
Author

dgroh commented Oct 25, 2017

@miyolou yes, this would be a workaround tho. this feature has been implemented in 2.6.0, so this should work also in this scenario imo, but yes, for now I'm using displayDate as workaorund.

@dgroh
Copy link
Author

dgroh commented Oct 25, 2017

@vlio20 using ...this.dateToTop is overriding the format configuration, note that the format is DD.MM.YYYY but fater overriding it it gets MM-DD-YYYY

@vlio20
Copy link
Owner

vlio20 commented Oct 25, 2017

  1. @dgroh it is a bug that the min display date is not changing after the config update.
  2. I will check why the format is being changed.

@vlio20 vlio20 added the bug label Oct 25, 2017
@vlio20
Copy link
Owner

vlio20 commented Oct 25, 2017

@dgroh, here is a better configuration: https://stackblitz.com/edit/angular-3h4a7c?file=app%2Fapp.component.ts

There is still some issue with the min date in the "to" calendar.

@dgroh
Copy link
Author

dgroh commented Oct 25, 2017

Thanks for your help

@vlio20 vlio20 self-assigned this Nov 1, 2017
@vlio20 vlio20 changed the title Set min property dydamically Set min property dynamically Nov 1, 2017
vlio20 added a commit that referenced this issue Nov 1, 2017
vlio20 added a commit that referenced this issue Nov 2, 2017
* fixes #269

* reverting demo page

* fixing lint

* fixing e2e

* fixing bugs
@vlio20
Copy link
Owner

vlio20 commented Nov 2, 2017

resolved in 969eb01

@vlio20 vlio20 closed this as completed Nov 2, 2017
vlio20 added a commit that referenced this issue Nov 3, 2017
* fixes #269

* reverting demo page

* fixing lint

* fixing e2e

* fixing bugs
@dgroh
Copy link
Author

dgroh commented Nov 10, 2017

Hi :)

Could you solve the point 2 mentioned above?

2. I will check why the format is being changed.

There was no bug open for this issue. Shall I open one or is this on the track?

@vlio20
Copy link
Owner

vlio20 commented Nov 10, 2017

Please open a new ticket. It should not be changed. Please put a new stackblitz there, with latest version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants