I have the Essential JS 2 CSS and JS referenced from the CDN.
If I use JS directly to create a control, it works great.
// initialize DatePicker component
var datepicker = new ej.calendars.DatePicker();
// Render initialized DatePicker.
If I try to do similar from a TS file I get compile errors that ej isn't known.
Installing the @types/ej.web.all via NPM helps. ej.calendars doesn't exist but ej.DatePicker is now recognised. It expects at least one arg in order to compile though. The below compiles but gives a TypeError: ej.DatePicker is not a constructor.
let el = $("#element");
var datepicker = new ej.DatePicker(el);
What's the correct way to use the EJ2 DatePicker in this situation please?
It works if I take a different approach but then it's a generic jQuery object rather than something typed.
Note: For your provided code block, you have referred the EJ2 component scripts and styles in your application but tried to render the EJ1 components. Could you please ensure to whether you have used EJ1 or EJ2 components in your application?
Could you please check the above provided information’s and get back to us, if you require any further assistance on this?
EESeptember 18, 2019 04:40 AM
Thanks for replying.
I looked at that exact link already.
I don't want to use RequireJS, SystemJS, WebPack or any of those at the moment but your documentation seems to suggest that EJ2 is not usable without?
I have only EJ2 referenced as per the CDN links I showed above so I would expect it's the EJ2 controls I'm using?
I really just need to know if/how I can reference EJ2 in a TS file so the TypeScript compiles or if I have to revert to hand-coded JS for the Syncfusion parts.
VKVinoth Kumar Sundara Moorthy Syncfusion Team September 19, 2019 08:29 AM
Good day to you.
We have created a sample to render DatePicker using direct script. Please check the sample in below link,
Could you please check the above sample and get back to us if you need any further assistance on this?
Vinoth Kumar S
EESeptember 19, 2019 09:01 AM
Sorry, I'm clearly not explaining things well. I expected this would be a straightforward answer.
That's all fine till I want to use the SF controls.
VKVinoth Kumar Sundara Moorthy Syncfusion Team September 20, 2019 09:10 AM
Good day to you.
/// <reference path="./ej2.d.ts" />
let datepicker:any = new ej.calendars.DatePicker();
Please follow the below steps to complile the file.
1.Open cmd in JavacsriptInTypescript folder
It will compile and generate the js file. Refer the generated app.js into the script in HTML file.