hsuanxyz / ion2-calendar

📅 A date picker components for ionic2 /ionic3 / ionic4
https://hsuanxyz.github.io/demo/ion2-calendar/
MIT License
555 stars 278 forks source link

Ionic 4 error configuration #215

Closed stoppiNeobiz closed 5 years ago

stoppiNeobiz commented 5 years ago

Ionic version: (check one with "x") [ ] 2.x [ ] 3.x [x] 4.x

Ion2-calendar mode: (check one with "x") [x] components mode [ ] modal mode

I'm submitting a ... (check one with "x") [ ] bug report [ ] feature request [x] help me

Hi, after configuration I recite this error: StaticInjectorError(AppModule)[Icon -> Config]: .... StaticInjectorError(Platform: core)[Icon -> Config]: NullInjectorError: No provider for Config!

I've import CalendarModule on app.module.ts and my page.module.ts

thanks

stoppiNeobiz commented 5 years ago

no help?

manmohanagarwal4 commented 5 years ago

same error here. Did you resolve it?

happy2share commented 5 years ago

Working for me by using dev branch and loading lazily within the page required. I have used range as pickMode. Here is the sample:

test.html:

<ion-content padding>
  <ion-calendar [(ngModel)]="dateRange"
                (change)="onChange($event)"
                [type]="type"
                [format]="'YYYY-MM-DD'"
                [options]="optionsRange">
   </ion-calendar>
</ion-content>

test.page.ts:

import { Component, OnInit } from '@angular/core';

import { CalendarComponentOptions } from '../components/ion2-calendar';
import * as moment from 'moment';

@Component({
  selector: 'app-test',
  templateUrl: './test.page.html',
  styleUrls: ['./test.page.scss'],
})
export class TestPage implements OnInit {

  dateRange: { from: string; to: string; };
  type: 'string'; // 'string' | 'js-date' | 'moment' | 'time' | 'object'

  optionsRange: CalendarComponentOptions = {
    pickMode: 'range',
  };
  address: Object;

  constructor() { }

  ngOnInit() {
    this.menuCtrl.enable(true);
    this.address = {
      place: ''
    };
  }

  onChange($event: any) {
    console.log($event);
  }
}

test.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';

import { IonicModule } from '@ionic/angular';
import { CalendarModule } from '../components/ion2-calendar';

import { TestPage } from './test.page';

const routes: Routes = [
  {
    path: '',
    component: TestPage
  }
];

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    IonicModule,
    RouterModule.forChild(routes),
    CalendarModule
  ],
  declarations: [TestPage]
})
export class TestPageModule {}
ulesta commented 5 years ago

@stoppiNeobiz Which version of Ionic 4 are you running?

ulesta commented 5 years ago

@alpesh12 This isn't the place to advertise your own calendar library, please be considerate of the developers who are in need of support. Thank you.

alpesh12 commented 5 years ago

Okay

no-response[bot] commented 5 years ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

obkdev commented 5 years ago

I'm having the same problem. I have implemented @happy2share 's code and am still facing the same issue. I must be leaving something out. What does your app.module.ts look like?