nkalinov / ng2-datetime

Datetime picker plugins wrapper for Angular2+
https://nkalinov.github.io/ng2-datetime
MIT License
157 stars 110 forks source link

datepicker is not a function #53

Closed DominicSachs closed 8 years ago

DominicSachs commented 8 years ago

My Imports: `import { NKDatetimeModule } from "ng2-datetime/ng2-datetime";

@NgModule({ imports: [FormsModule, ReactiveFormsModule, CommonModule, NKDatetimeModule], declarations: [AppComponent] }) export class MyModule { }`

My HTML: <datetime [timepicker]="false" [formControl]="form.controls['startDate']"></datetime>

I already tried the solution from this Issue. Is there anything to do to make it working?

jQuery: 2.2.3 Angular: 2.0.0 (final) Webpack: 1.13.0

nkalinov commented 8 years ago

Which version are you using ? 1.2.0 should resolve this

DominicSachs commented 8 years ago

There was a missing import in my code. Now i always get the error "No provider for NgControl".

<form [formGroup]="form" novalidate> <datetime [timepicker]="false" [(ngModel)]="model.date" formControlName="date"></datetime> </form>

cwienands1 commented 7 years ago

I solved it the following way: Disclaimer, I'm not using vendor.ts and my project started from angular2-webpack-starter, with angular2-webpack-starter-bootstrap merged in.

In styles.scss: @import '~bootstrap/dist/css/bootstrap.min.css'; @import '~bootstrap/dist/css/bootstrap-theme.min.css'; @import '~bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css'; @import '~bootstrap-timepicker/css/bootstrap-timepicker.min.css';

In app.module.ts: ... import '../styles/styles.scss'; import 'jquery/dist/jquery.min.js' import 'bootstrap/dist/js/bootstrap.js'; import 'bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js'; import 'bootstrap-timepicker/js/bootstrap-timepicker.min.js'; import { NKDatetimeModule } from 'ng2-datetime/ng2-datetime'; ... @NgModule({ imports: [ ... NKDatetimeModule, ], ...

drunkendaddy commented 7 years ago

I added the following entries to angular.cli.json and it works.

"styles": [
        "styles.css",
        "../node_modules/font-awesome/css/font-awesome.css",
        "../node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.min.js",
        "../node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js",
        "../node_modules/bootstrap-timepicker/js/bootstrap-timepicker.js"
      ]