Code Monkey home page Code Monkey logo

Comments (15)

PhilippeOberti avatar PhilippeOberti commented on June 27, 2024 1

thanks for the answer, the only way I got it working was to write this:

(<any> window).moment = require('moment');

once somewhere in the code, and then in every file that uses moment do this

declare var moment: any;

thanks for the help!!

from md-date-time-picker.

jolic avatar jolic commented on June 27, 2024

Got it:

import mdDateTimePicker from "md-date-time-picker";
...
var dateDialog = new mdDateTimePicker({
  type: 'date'
});

from md-date-time-picker.

puranjayjain avatar puranjayjain commented on June 27, 2024

@jolic also the new keyword will be like this in v2.0.0

var dialog = new mdDateTimePicker.default({
        type: 'date'
});

Feel free to close this issue if it is resolved 😄

from md-date-time-picker.

jolic avatar jolic commented on June 27, 2024

I'm just inspecting the source and I think it would be better to provide callbacks on the constructor:

var dateDialog = new mdDateTimePicker({
  type: "date"
  ,past: moment().subtract(3, 'years')
  ,future: moment()
  ,onClick: function(date){
    console.log(date);
  }
  ,onOk: function(date){
    console.log(date);
  }
  ,onCancel: function(date){
    console.log(date);
  }
});
...

function mdDateTimePicker(_ref) {
...
                    _ref$onClick = _ref.onClick,
                onClick = _ref$onClick === undefined ? '' : _ref$onClick,
                    _ref$onOk = _ref.onOk,
                onOk = _ref$onOk === undefined ? '' : _ref$onOk,
                    _ref$onCancel = _ref.onCancel,
                onCancel = _ref$onCancel === undefined ? '' : _ref$onCancel;
...
            this._onClick = onClick;
            this._onOk = onOk;
            this._onCancel = onCancel;
...
            value: function _addCellClickEvent(el) {
...
                        // update temp date object with the date selected
                        me._sDialog.sDate = currentDate.clone();
                        if (me._onClick) {
                            me._onClick(me._sDialog.sDate);
                        }
                        me._fillText(subtitle, currentDate.year());
....

from md-date-time-picker.

jolic avatar jolic commented on June 27, 2024

With this you didn't depend on an element and it's clearer for the user...
What do you think?

from md-date-time-picker.

jolic avatar jolic commented on June 27, 2024

Maybe it would be nice to contribute the datepicker to https://github.com/tleunen/react-mdl

from md-date-time-picker.

puranjayjain avatar puranjayjain commented on June 27, 2024

@jolic i'll start a pr there in some time for the component (possibly two of them)

About the callbacks can you start a PR?

from md-date-time-picker.

puranjayjain avatar puranjayjain commented on June 27, 2024

@jolic also if possible can this callback solution be done in a way that we don't have any breaking changes?

Also, how does react mdl differ from material ui? Any ideas?

from md-date-time-picker.

PhilippeOberti avatar PhilippeOberti commented on June 27, 2024

hey guys, quick question: I'm using datetime picker in a project with Webpack. in my vendor.ts file I load moment and the datetime picker as follow

import 'moment';
import 'md-date-time-picker';

then in my angular2 component I'm using moment and the datetime picker like this

let moment = require('moment');
let mdDateTimePicker = require('md-date-time-picker');

From my angular2 component I can use moment no problem but as soon as I initialize the datetime picker

var dialog = new mdDateTimePicker.default({
    type: 'date'
});

it throws an exception

picker

any idea?
thanks a lot!!

Philippe

from md-date-time-picker.

puranjayjain avatar puranjayjain commented on June 27, 2024

@filoucpp you need to configure webpack as done here:
https://webpack.github.io/docs/library-and-externals.html

or modify your require statements as

window.moment = require('moment');
const mdDateTimePicker = require('md-date-time-picker');

from md-date-time-picker.

puranjayjain avatar puranjayjain commented on June 27, 2024

@filoucpp congrats it worked for you and thanks for posting the answer too! It would help a lot of people in the future 😄

from md-date-time-picker.

DenysVuika avatar DenysVuika commented on June 27, 2024

Could you please provide a clear example on using with code splitting and webpack? Tried numerous approaches and md-date-time-picker just does not work.

vendors.ts
css seems to be working:

import 'md-date-time-picker/dist/css/mdDateTimePicker.css';

not working

import 'md-date-time-picker';
import 'md-date-time-picker/dist/js/mdDateTimePicker.min.js';
require('md-date-time-picker');

Thanks in advance

from md-date-time-picker.

puranjayjain avatar puranjayjain commented on June 27, 2024

Hmm seems to be an issue

from md-date-time-picker.

DenysVuika avatar DenysVuika commented on June 27, 2024

Any updates on the issue?

from md-date-time-picker.

puranjayjain avatar puranjayjain commented on June 27, 2024

Cant say yet will try my best to release it asap.

from md-date-time-picker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.