nb-rangepicker - validation - min/max - ngModel - issue
See original GitHub issueIssue type
I’m submitting a … (check one with “x”)
- bug report
- feature request
Issue description
Current behavior: ERROR Error: Uncaught (in promise): TypeError: date2.getTime is not a function TypeError: date2.getTime is not a function at NbNativeDateService.push…/node_modules/@nebular/theme/components/calendar-kit/services/native-date.service.js.NbNativeDateService.compareDates (native-date.service.js:108)
Expected behavior: Nebular 3 - components - form - datepicker -rangepicker to work with [min] and [max] being set.
Both range and date pickers support all parameters as calendar, so, check NbCalendarComponent for additional info.
Steps to reproduce: https://stackblitz.com/edit/nebular-1281-kmwnav?file=src/app/app.component.ts Using the Validation template replace ‘nb-datepicker’ to ‘nb-rangepicker’ and using [(ngModel)]
Related code:
/*
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { Component } from '@angular/core';
import { NbDateService } from '@nebular/theme';
@Component({
selector: 'nb-datepicker-validation',
template: `
<div>
<input nbInput placeholder="Form Picker" [nbDatepicker]="picker" [(ngModel)]="ngModelDate">
<nb-rangepicker #picker [min]="min" [max]="max"></nb-rangepicker>
</div>
`,
styles: [`
:host {
display: flex;
justify-content: center;
align-content: center;
height: 40rem;
}
:host input {
width: 21.875rem;
}
`],
})
export class DatepickerValidationComponent {
min: Date;
max: Date;
ngModelDate = {
start: new Date(),
end: new Date(),
};
constructor(protected dateService: NbDateService<Date>) {
this.min = this.dateService.addMonth(this.dateService.today(), -1);
this.max = this.dateService.addMonth(this.dateService.today(), 1);
}
}
Other information:
npm, node, OS, Browser
Node v11.6.0, npm 6.9.0
OS: macOS (Mojave)
Browser: Chrome
Angular, Nebular
"@angular/animations": "^7.2.8",
"@angular/cdk": "^7.3.3",
"@angular/common": "^7.2.8",
"@angular/compiler": "^7.2.8",
"@angular/core": "^7.2.8",
"@angular/forms": "^7.2.8",
"@angular/material": "^7.3.3",
"@angular/platform-browser": "^7.2.8",
"@angular/platform-browser-dynamic": "^7.2.8",
"@angular/router": "^7.2.8",
"@nebular/theme": "^3.4.2",
"angular2-chartjs": "^0.5.1",
"chart.js": "^2.7.3",
"core-js": "^2.6.3",
"hammerjs": "^2.0.8",
"nebular-icons": "^1.1.0",
"ng2-completer": "^2.0.8",
"ng2-smart-table": "^1.3.5",
"ngx-markdown": "^8.0.2",
"rxjs": "~6.4.0",
"rxjs-compat": "^6.4.0",
"tslib": "^1.9.0",
"zone.js": "^0.8.29"
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:8
Top GitHub Comments
managed to workaround it by overriding the comparison method to suit the formControl with the rangePickerDirective in the following manner.
and in template
@zhanghongyublog I have the same problem. FormControl With min and max throw the error “date.clone is not function”