Angular 4 - kekeh/mydatepicker -
i using package work dates: https://github.com/kekeh/mydatepicker
it working ok, have error in browser console:
vm417:1 uncaught typeerror: cannot read property 'core' of undefined @ eval (eval @ webpackjsonp.123.module.exports (addscript.js:9), :1:309) @ eval (eval @ webpackjsonp.123.module.exports (addscript.js:9), :1:339) @ eval () @ webpackjsonp.123.module.exports (addscript.js:9) @ object.438 (mydatepicker.umd.min.js?d1d4:1) @ webpack_require (bootstrap 112b9ba0fd4a31e4bb08:52) @ object.821 (scripts.bundle.js:96) @ webpack_require (bootstrap 112b9ba0fd4a31e4bb08:52) @ webpackjsonpcallback (bootstrap 112b9ba0fd4a31e4bb08:23) @ scripts.bundle.js:1
the application angular cli (angular-cli.json):
"scripts": [ "js/libs/popper.min.js", "../node_modules/jquery/dist/jquery.min.js", "../node_modules/moment/min/moment.min.js", "../node_modules/mydatepicker/bundles/mydatepicker.umd.min.js", "../node_modules/bootstrap/dist/js/bootstrap.min.js" ], this component complete:
import { component } '@angular/core'; import {imydpoptions} 'mydatepicker'; @component({ selector: 'prices', templateurl: '../views/price.component.html' }) export class pricecomponent{ private mydatepickeroptions: imydpoptions; // initialized specific date (09.10.2018). //private model: object = { date: { year: 2018, month: 10, day: 9 } }; public titulo: string; constructor( ){ this.titulo = 'prices'; this.mydatepickeroptions = { // other options... dateformat: 'dd/mm/yyyy', }; } ngoninit(){ console.log('prices.component.ts loaded'); } } this html code:
<my-date-picker name="start" [options]="mydatepickeroptions" [(ngmodel)]="datestart"></my-date-picker> as said, works fine, , can select dates, not error in browser console.
how can solve it?
you should initialize mydatepickeroptions in constructor:
this.mydatepickeroptions = { dateformat: 'dd/mm/yyyy', // maxyear: new date().getfullyear(), editabledatefield: false, showtodaybtn: false, showcleardatebtn: false, // height: '46px', disablesince: { year: new date().getfullyear() - 13, month: new date().getmonth() + 1, day: new date().getdate() + 1 } };
Comments
Post a Comment