kekeh / angular-mydatepicker

Angular datepicker and date range picker :date:
https://kekeh.github.io/angular-mydatepicker/
MIT License
1 stars 11 forks source link

no directive with "exportAs" set to "angular-mydatepicker" #11

Closed seanFTW closed 5 years ago

seanFTW commented 5 years ago

I saw this issue mentioned in another conversation but wasn't able to resolve it with what was suggested there.

I'm hoping to add this to an npm component library we're building at work! It works in the base level app component, and even works when I paste it into another component template/module (I had date selectors under every checkbox instance when I added it to the checkbox component).

So its kind of working - only putting it into a dedicated component gives me the "no directive with "exportAs" set to "angular-mydatepicker"" error! I've tried adding ReactiveFormsModule, FormsModule, and AngularMyDatePickerModule to every NgModule imports array in the app - but still I can't get it working in a component by itself.

seanFTW commented 5 years ago

Here's the full error compiler.js:2427 Uncaught Error: Template parse errors: There is no directive with "exportAs" set to "angular-mydatepicker" ("epicker name="mydate" (click)="dp.toggleCalendar()" [(ngModel)]="model" [options]="myDpOptions" [ERROR ->]#dp="angular-mydatepicker" (dateChanged)="onDateChanged($event)" /> </div>"): ng:///BluFormsModule/DatePickerComponent.html@2:78 Can't bind to 'ngModel' since it isn't a known property of 'input'. ("older="Click to select a date" angular-mydatepicker name="mydate" (click)="dp.toggleCalendar()" [ERROR ->][(ngModel)]="model" [options]="myDpOptions" #dp="angular-mydatepicker" (dateChanged)="onDateChang"): ng:///BluFormsModule/DatePickerComponent.html@2:34 Can't bind to 'options' since it isn't a known property of 'input'. ("ct a date" angular-mydatepicker name="mydate" (click)="dp.toggleCalendar()" [(ngModel)]="model" [ERROR ->][options]="myDpOptions" #dp="angular-mydatepicker" (dateChanged)="onDateChanged($event)" /> </div"): ng:///BluFormsModule/DatePickerComponent.html@2:54

seanFTW commented 5 years ago

Hey guys, someone else on my team figured this out -

If you run into the same problem, you gotta fix your imports on whatever module you're importing this component to. When running "ng g c", it includes an import for the component. You need to change the component import to a module import!

kekeh commented 5 years ago

Did you find a solution? If yes what uou did.

What do you mean "You need to change the component import to a module import!"?

seanFTW commented 5 years ago

I added the module file after generating the component, but the rest of the app was still importing the component file rather than the module file (date-picker.module.ts instead of date-picker.component)