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

Provider for NgModel is no longer needed in @Directive() #57

Open
mtnair opened this issue Aug 26, 2020 · 5 comments
Open

Provider for NgModel is no longer needed in @Directive() #57

mtnair opened this issue Aug 26, 2020 · 5 comments

Comments

@mtnair
Copy link

mtnair commented Aug 26, 2020

(I know this component was made for Ionic 4, though I encountered following problem with Ionic 5 and Angular 9; I don't know whether this still works with Ionic 4)

When using the directive to add the date picker to an ion-input, the input field doesn't update its value to the picked date.
It took me a while to find out why, it seems like the providers: [NgModel] option in the @Directive() decorator is the issue. When removing this line, the date picker works as expected. See: https://github.com/logisticinfotech/ionic4-datepicker/blob/master/projects/ionic4-datepicker/src/lib/li-ionic4-datepicker.directive.ts#L12

@Directive({
  selector: '[customIonicDatepicker]',
  exportAs: 'customIonicDatepicker',
  providers: [NgModel], // remove this line
})
@maxcook
Copy link

maxcook commented Aug 31, 2020

How can i fix that on my local? (Sorry for the stupid question, i am new)

This repository is dead - we might never see it being fixed or even updated for ionic 5

@mtnair
Copy link
Author

mtnair commented Sep 1, 2020

How can i fix that on my local? (Sorry for the stupid question, i am new)

Honestly, I don’t know. I cloned the repo and copied the code from the plugin to my codebase and fixed it myself by editing the code. I also fixed other problems mentioned in other issues (ionicons, footer height).

@maxcook
Copy link

maxcook commented Sep 1, 2020

Ok i see. It would be awesome if you could push that stuff to github for us to also use :)

@RomuloPBenedetti
Copy link

A workaround for this problem is to invoke the datepicker from code side:

async openDatePicker() {
    const datePickerModal = await this.modalCtrl.create({
        component: Ionic4DatepickerModalComponent,
        cssClass: 'li-ionic4-datePicker',
        componentProps: { 'objConfig': this.datePickerObj }
    });
    await datePickerModal.present();

    datePickerModal.onDidDismiss().then((data) => {
        this.myDate = data.data.date;
    });
}
<ion-input placeholder="bla" readonly [(ngModel)]="myDate" (click)="openDatePicker()"> </ion-input>

@ipehimanshu
Copy link

Hello

@RomuloPBenedetti

do you face issue like

Error: NG0906: The Ionic4DatepickerModalComponent is not an Angular component, make sure it has the @Component decorator.

Let me know if yes and you already fix

Thank you

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

No branches or pull requests

4 participants