Code Monkey home page Code Monkey logo

ion-datepicker's Introduction

How to use

1) Install using npm

    npm i ion-datepicker --save

2) Add it to your ngModule in app.module

 import { DatePickerModule } from 'ion-datepicker';
   imports: [
        IonicModule.forRoot(App),
        DatePickerModule,
    ],

3) Use the directive ion-datepicker in your html

	<span ion-datepicker  [(value)]="localDate" [min]="localDate" clear class="ScheduleDate">
		<span>{{localDate | date}} <ion-icon name="clipboard" item-left ></ion-icon> </span>
	</span>

Dismiss the datepicker from the class


    import { DatePickerDirective } from 'ion-datepicker';

	@ViewChild(DatePickerDirective) private datepickerDirective:DatePickerDirective;

    public closeDatepicker(){
        this.datepickerDirective.modal.dismiss();
    }
    

Options

[value] - defines the initial value, can be two bindable as in [(value)].

[min] - minimum date that user is allowed to select. (not required)

[max] - maximum date that user is allowed to select. (not required)

[disabledDates] - An array of dates that should be disabled (not required)

[calendar] - A boolean that determines whether to show calendar or not. Defaults to true.

[markDates] - An array of dates that should be marked with background color (not required)

(ionChanged) - an event emitter that returns the date as a $event.

(ionCanceled) - an event that is raised when the cancel button is activated. Returns no data.

(ionSelected) - an event that is raised when a date is selected

[headerClasses] - a bridge to the header classes of the directive using ngClass (string, array or object) (not required)

[bodyClasses] - a bridge to the date classes of the directive using ngClass (string, array or object) (not required)

[modalOptions] - a modal is used to display the picker to configure the animation or other options you may use this

[locale] - for translating the calendar. Avaliable local is en-US, en-UK, he-IL, pt-BR, ru-RU, de, fi, fr-FR, zh-TW, zh-CN, ja-JP. Please note en-US locale starts the calendar with monday and en-UK starts it with sunday

[localeStrings] - if you dont want to use the built translations - accepts an object { weekdays: string[], months: string[], monday:boolean }, For example: { monday:true, weekdays: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'], months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] },

[okText] - text for the ok button

[cancelText] - text for the cancel button

4) Pictures

ion-datepicker's People

Contributors

anxorl avatar askrenteam avatar celsomarques avatar dependabot[bot] avatar jetro223 avatar misha130 avatar mvidailhet avatar niklilland avatar paul-etienne avatar paulo-rosa-procergs avatar ross-nordstrom avatar venalil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ion-datepicker's Issues

Shown date is always today

The Selected date is allways today and not the value that i defined.
bildschirmfoto vom 2017-06-28 um 18 07 52

But when i press cancel the right date is flashing up and it closes imediately.

How can i resolve this issue?
I belive it has to behave like in the gif in #9 .

export class EditEvent {
  initDate:Date=Date.parse('yesterday -6 days');
  constructor(public navCtrl: NavController, public navParams: NavParams) {

  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad EditEvent id:', this.navParams.get('id'));
  }

  setDate(date: Date){
    console.log(date);
    this.initDate=date;
  }

}
<ion-content padding>
  <span ion-datepicker
  (ionChanged)="setDate($event);"
  [value] = "initDate"
  [locale] = "'Pages.EditEvent.datepickerLang' | translate"
  [okText] = "'alert.ok' | translate"
  [cancelText] = "'alert.cancel' | translate"
  clear class="ScheduleDate">
		<span>{{initDate | date}} <ion-icon name="clipboard" item-left ></ion-icon> </span>
	</span>
</ion-content>

ionic info:

Your system information:

Cordova CLI: 6.5.0 
Ionic Framework Version: 3.4.2
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.0
ios-deploy version: 1.9.0 
ios-sim version: 5.0.13 
OS: macOS Sierra
Node Version: v6.9.4
Xcode version: Xcode 8.2.1 Build version 8C1002

Cannot use with --prod

All works well, but if I try to deploy on the device with --prod configuration and use the directive, the following error is thrown:

ERROR Error: Uncaught (in promise): Error: No component factory found for undefined. Did you add it to @NgModule.entryComponents?
Error: No component factory found for undefined. Did you add it to @NgModule.entryComponents?

Ok and Cancel button texts are missing

Even with okText and cancelText, the text on the buttons is empty:

<span ion-datepicker (ionChanged)="onSetDate($event);" (ionCanceled)="onCancelDate($event);" [value]="localDate" [min]="localDate" full="false" calendar="true" class="ScheduleDate" [okText]="Ok" [cancelText]="Cancel">

This is with Ionic 3.5

Set Min Date, Move to next months and click previous is not working..

Set Min & Max Dates
min:new Date(),
max:new Date(new Date().setDate(new Date().getDate()+30)),

Below is the HTML -
<span ion-datepicker (ionChanged)="eventFromDate($event);" [value]="from" [min]="min" full="true" calendar="true" clear class="ScheduleDate">
{{from | date:'dd-MM-yyyy' }}

Now click on next month button for few times - Move to couple of months, and click back to go previous month, but it will not work.

Brilliant!

I am not reporting on an issue here, just wanted to say thank you for a brilliant job! There were no problems installing, it worked on the first try, and it was not hard to change any functionality to my needs. I also changed the UI to fit in with my design. Once again - thank you very much!

image

ionSelected function

Hey, I'm really liking this library! I am curious if the ionSelected function found on the interface is going to be implemented? I see it's in the code, but not in the Readme. For the functionality I'm looking for, I need to have a function to handle every time a date is selected.

Thanks!

Hard coded platform style?

Why does the component has these hard coded style? Example:

<button (tap)="onDone($event)" ion-button="" class="button button-clear button-small disable-hover button button-ios button-default button-default-ios"> <span class="button-inner">{{config.okText || 'OK'}}</span><div class="button-effect"></div> </button>

bind `date | date` into variable.

Hello,
I have Ionic2 application that I chosed to use your repo,
I'm trying to make this kinda thing to work:
<ion-input full="true" [min]="HerdDate" ion-datepicker type="text" [(ngModel)]="HerdDate" value="{{HerdDate | date}}">

HerdDate is public HerdDate: Date = new Date();
when I do {{ HerdDate | date }} on the template I get 8 Jan, 2017 and I would like to push that results into HerdDate how can I do it?
Thanks

BTW ~ There is a way to design the DatePicker?

change date format

is it possible to change date display format to "dd/MM/yy" from " Thu Aug 31 2017 16:56:13 GMT+0530 (IST)"

Weekdays not shown or aligned

I just noticed that the calendar modal doesn't show the weekdays for me, and the dates are oddly aligned.
I would expect the calendar to have a header like [S, M, T, W, Th, F, Sa] and for the dates to align with that.

Instead, I get Sunday showing up in a middle column:

2017-03-11-171324_942x1071_scrot

Error on localeStrings

Hi i have an issue when i set the localeStrings. It look as follows:

Cannot read property 5 of undefined at datepickercomponent.getSelectedWeekday. Here is the object i used:

{
monday: true,
weekdays: ['Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado', 'Domingo'],
months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"]

}

Lazy Loading Issue

Hi Misha,

We recently updated our project to ionic 3 and changed all the pages to lazy loading(added one more module.ts). Right now, every page will blow out if that page has datepicker-ionic2 included.
The main error is "Can't bind to 'Value' since it isn't a known property fo span. (ionCHanged) ='xxx' ".

Do you have any suggestion? please help.

problem changing years

Hello, you did a great job with this component thank you. I post this message because I am struggling trying to change the years, there is no way I can modify by clicking on it. Maybe I made a stupid mistake but I will be grateful if you can help me.

Also, is there a way to modify the theme color (primary, secondary color...) ?

capt
capt2

Thanks, Nicolas

Problem with year , month and date select

When we select a year from the dropdown option, the year is getting selected but after the year is selected, you go and select the date from calendar, the year is changing again by itself.
Please look into this issue.

need compact design in desktop version

Hi,
I am planning to use ion-datepicker for both mobile devices and desktop. For mobile devices the look is perfect usability wise. But in desktop full screen date picker looks a bit weird. Is there a way to have a small size date picker for desktop.
I can see that in previous version there was a full property which isn't there now. Can you please guide me with the same.
Thanks in advance.

Month with first day = sunday and week starts from monday -> disappearing days...

Hello,

In october 2017 the first day is a sunday, if you have a datepicker with "doesStartFromMonday === true" then the first day is not shown. (see screenshot)

I've fixed it by adding 1 line DatePicker.service ->
DateService.createDateList(currentDate) {
var firstDayOfWeek = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1).getDay();
if (this.doesStartFromMonday() && firstDayOfWeek === 0) firstDayOfWeek = 7;
...
}

It would be nice if you could fix this in the npm archive, otherwise we'll have to copy the datepicker files into our source tree.

many thanks,
Johan.

screen shot 2017-09-19 at 12 04 18

Can't bind to 'value' since it isn't a known property of 'span'.

I tried to use this calendar but it gives me this error,

<span ion-datepicker (ionChanged)="setDate($event)"
[ERROR ->][value]="localDate"
[min]="localDate"
full="true"
"): ng:///AppModule/TrackerPage.html@13:2
Can't bind to 'min' since it isn't a known property of 'span'.

Dismiss from directive oncorrect

The example in the Readme file for dismissing the datepicker through the class is incorrect. It should be this:

Dismiss the datepicker from the class


    import { DatePickerDirective } from 'ion-datepicker';

	@ViewChild(DatePickerDirective) private datepickerDirective:DatePickerDirective;

    public closeDatepicker(){
        this.datepickerDirective.modal.dismiss();
    }
    

Note this is ionic 3.6.1

Click-Event Issue on iOS

If I add the ion-datepicker directive, like in your example, to a span, the icon has to be touched twice to open the calendar.
The solution for this problem is to use a button or add the attribute "tabbable" (Description: http://technotip.com/5093/tappable-attribute-ionic-2/)

but then I have another problem. The date-selection does not work on every click. With the span and no tabbable attribute its fine.

Can anyone reproduce it?
I used an iPad Air with iOS 10.

Error when trying build project with --prod

Hi Misha130,
When I try to to build the project by using the command 'ionic build android --prod', it give me error. But it works if I remove the '--prod' and that will build in dev mode. I did some search on google, some guys said that is because your datepicker module does not support aot compiler.

Please help. Here is the error details:

ionic-app-scripts build "--prod"

[10:17:57] ionic-app-scripts 1.0.0
[10:17:57] build prod started ...
[10:17:57] clean started ...
[10:17:57] clean finished in less than 1 ms
[10:17:57] copy started ...
[10:17:57] ngc started ...
[10:17:58] build prod failed: Unexpected value 'DatePickerModule' imported by the module 'AppModule'
[10:17:58] ionic-app-script task: "build"
[10:17:58] Error: Unexpected value 'DatePickerModule' imported by the module 'AppModule'
Error: Unexpected value 'DatePickerModule' imported by the module 'AppModule'
at /Users/johnlu/Documents/logile/hybrid/newsvn/ELM/node_modules/@angular/compiler/bundles/compiler.umd.js:14675:33
at Array.forEach (native)
at CompileMetadataResolver._loadNgModuleMetadata (/Users/johnlu/Documents/logile/hybrid/newsvn/ELM/node_modules/@angular/compiler/bundles/compiler.umd.js:14660:51)
at CompileMetadataResolver.getUnloadedNgModuleMetadata (/Users/johnlu/Documents/logile/hybrid/newsvn/ELM/node_modules/@angular/compiler/bundles/compiler.umd.js:14636:23)
at addNgModule (/Users/johnlu/Documents/logile/hybrid/newsvn/ELM/node_modules/@angular/compiler/bundles/compiler.umd.js:12944:43)
at /Users/johnlu/Documents/logile/hybrid/newsvn/ELM/node_modules/@angular/compiler/bundles/compiler.umd.js:12957:16
at Array.forEach (native)
at _createNgModules (/Users/johnlu/Documents/logile/hybrid/newsvn/ELM/node_modules/@angular/compiler/bundles/compiler.umd.js:12956:28)
at analyzeNgModules (/Users/johnlu/Documents/logile/hybrid/newsvn/ELM/node_modules/@angular/compiler/bundles/compiler.umd.js:12700:16)
at analyzeAndValidateNgModules (/Users/johnlu/Documents/logile/hybrid/newsvn/ELM/node_modules/@angular/compiler/bundles/compiler.umd.js:12704:20)

npm ERR! Darwin 15.6.0

Weekday off by one day

screenshot
When using a locale with the week starting on monday, the week day in the header is off by one day. As you can see in the screenshot, the day is supposed to be Friday, but Saturday is shown.
The problem doesn't occur with locale 'en-UK', so I'm guessing it has to do with the week starting on monday.

[email protected] not worked on Android with --prod mode

[email protected] does not work on Android with --prod mode
Build success, but when in app datepicker is called, in console:
Error: Uncaught (in promise): Error: No component factory found for undefined. Did you add it to @NgModule.entryComponents?

Without "--prod" works fine.

Thanks in advance for the help.

cli packages:
    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

global packages:
    Cordova CLI : 7.0.1

local packages:
    @ionic/app-scripts : 2.1.4
    Cordova Platforms  : android 6.2.3 ios 4.4.0
    Ionic Framework    : ionic-angular 3.6.0

System:
    Android SDK Tools : 25.2.5
    Node              : v7.10.0
    npm               : 4.5.0
    OS                : Windows 10

Select years

Hello,
I want to use this package to let the user select his birthday date. But they can't change the year directly. Is there a way to achieve this?
Thanks

Cancel doesn't work

I'm using this with
(ionChanged)="setDate($event);"

No matter if I click ok or cancel the setDate function is called. I need setDate to be called only when OK button is called. Thanks!

Bug with col ionic 2

Hi, when i click the datepicker and opens the modal, the cols of my page lost their css properties

How to remove the date,year on top of the page?

Hi Bro,
I am trying to remove the following:
1.submit and ok button.
2.day,month,year,date at top of the calendar. I wanted to display only calendar UI.
I am trying to remove but it is not removing.Hope you had understand my problem.Can you please tell me how to do

date error while converting IST to ISO

converting
Fri Aug 18 2017 00:00:00 GMT+0530 (India Standard Time)
to ISO using toISOString() getting as
2017-08-17T18:30:00.000Z
which is one day before
can you suggest how to convert in to ISO

Day Values (like in ion-datetime) in datepicker

Is there anyway of making days not pickable? like i want to disable all Mondays form being selected
This is available in the ionic DateTime component with the option Dayvalues.

So is this available with this module ?

cannot bind to value

I am getting below error any idea what am I doing wrong ?
ERROR Error: Uncaught (in promise): Error: Template parse errors: Can't bind to 'value' since it isn't a known property of 'span'. ("g> <span ion-datepicker locale="en" (ionChanged)="event($event)" okText="Ok" cancelText="Cancel" [ERROR ->][value]="localDate" clear > {{localDate | date:'dd-MM-yyyy' }}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.