Can't find a datepicker that plays nicely with angular-meteor

空扰寡人 提交于 2019-12-13 09:55:03

问题


I've tried to add a bunch of different datepicker libraries to my project:

  • Meteor 1.7
  • Angular 6
  • Bootstrap 4

For most of the packages that are intended for Angular I get an error during import on startup. The error normally looks similar. Here is the exact error from ng-bootstrap:

Uncaught Error: Can't resolve all parameters for NgbAlert: (?).

In the case of that error I have not included an NgbAlert anywhere, it's solely from adding NgbModule.forRoot() so don't let the alert confuse you, the issue definitely has something to do with importing the module.

I've tried:

  • ng-pick-datetime
  • Ngx-Bootstrap
  • ng-bootstrap
  • and some others

Any suggestions would be greatly appreciated!


回答1:


Semi-Solution

Set AOT=1 in meteor environment variables.

Discussion

I was able to get ng-bootstrap working by sym-linking the library (to ensure that it is transpiled) and then building Meteor with AOT enabled.

I narrowed down the original failure to an area in the Angular JIT compiler code. I really don't know a ton about how Angular-Meteor's angular-compiler code works, in relation to Angular's normal compile flow, so I can't really get to the root of the problem. If anyone can provide a lower level explanation, I'd really appreciate it!


Update

In a different, but similar question a better semi-solution was provided by ironmanu on this question. It's still not a perfect solution but it's a usable bandaid.

The solution is to add require('reflect-metadata'); to the top of the module imports in app.module.ts. This solves the issue during JIT. I'm not sure why the Angular compiler doesn't inherently take care of this issue, but this does the trick!




回答2:


I use angular material’s datepicker. It works well with angular-meteor.

I also use ngbootstrap in my app but find it more troublesome than angular material’s components. I’m gradually replacing most components with materials over time



来源:https://stackoverflow.com/questions/50768171/cant-find-a-datepicker-that-plays-nicely-with-angular-meteor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!