Comments (15)
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.
Got it:
import mdDateTimePicker from "md-date-time-picker";
...
var dateDialog = new mdDateTimePicker({
type: 'date'
});
from md-date-time-picker.
@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.
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.
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.
Maybe it would be nice to contribute the datepicker to https://github.com/tleunen/react-mdl
from md-date-time-picker.
@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.
@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.
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
any idea?
thanks a lot!!
Philippe
from md-date-time-picker.
@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.
@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.
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.
Hmm seems to be an issue
from md-date-time-picker.
Any updates on the issue?
from md-date-time-picker.
Cant say yet will try my best to release it asap.
from md-date-time-picker.
Related Issues (20)
- inline mode (without dialog) HOT 1
- Impossible to use theme from the library
- Disable specific time in time picker HOT 5
- Make hour draggable
- Make the draggable element 'touch' element larger but the actual visual red circle the same size? HOT 1
- CSP inline style conflict HOT 3
- Year selection not showing up on second click in IE 11 HOT 1
- Can we open date and time without dialog box? HOT 1
- Date picker has subtitle active when re-opened
- How to enable the future dates?, Default the future dates are disabled. HOT 2
- Cannot read property 'weekdaysMin' of undefined
- Got New issue, Date picking(value) is fine but i cant save the value. Got Error message like this.. HOT 2
- Year picker is not working for some initial dates on default
- Dynamic change past and future option HOT 6
- I tested IE Under version 10 HOT 1
- Dependencies not adequately listed in package.json HOT 4
- How do I change output format? Like I only want date in DD-MM-YYYY as output HOT 1
- Calendar(broken) Responsive issue -When Changing the year(navigating through month) HOT 1
- Uncaught TypeError: mdDateTimePicker.default is not a constructor HOT 1
- When mddtp-next-handle is clicked way to fast the calendar starts to stay on 1 month only during rendering HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from md-date-time-picker.