JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Date & Time Pickers › Typescript compile error Smart.Utilities.DateTime
Tagged: datetimepicker
- This topic has 11 replies, 2 voices, and was last updated 3 years, 5 months ago by admin.
-
AuthorPosts
-
July 2, 2021 at 9:46 am #101969davoutMember
I’m building an Angular app and using the Smart DateTimePicker component
In my Typescript file within IntelliJ editor , I’m getting an “TS2503: Cannot find namespace ‘Smart’.” error when Typescript is compiledimport {Component, OnDestroy, OnInit} from '@angular/core'; import {TaskUiMediator} from '../mediators/task.ui.mediator'; import {faArrowAltCircleLeft, faArrowAltCircleRight} from '@fortawesome/pro-light-svg-icons'; import {Smart} from 'smart-webcomponents-angular/datetimepicker'; import {TaskViewsService} from '../common/task-views.service'; import {TaskFilterMediator} from '../mediators/task.filter.mediator'; import {BehaviorSubject, Observable, Subscription} from 'rxjs'; import {DateFilterUtil} from '../mediators/DateFilterUtil'; import {DateUtil} from '../common/DateUtil'; @Component({ selector: 'app-task-week', templateUrl: './task-week.component.html', styleUrls: ['./task-week.component.css'] }) export class TaskWeekComponent implements OnInit, OnDestroy { public viewId = TaskViewsService.TASK_VIEW_WEEK; iconLeft = faArrowAltCircleLeft; iconRight = faArrowAltCircleRight; pageSize = 1000; private dateValueSubject = new BehaviorSubject<Smart.Utilities.DateTime>(new Smart.Utilities.DateTime(DateUtil.today()));
July 5, 2021 at 7:35 am #101972adminKeymasterHi davout,
There is not ‘Smart.Utilities.DateTime’ in ‘Smart’ typescript defs. That is the reason you’re getting typescript error.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/July 5, 2021 at 8:31 am #101974davoutMemberOk, so what ‘import’ and class name should be used in the TS file?
July 5, 2021 at 9:05 am #101975adminKeymasterHi davout,
We have multiple online demos for this component which show how to use it with Angular. You may look at them here: https://www.htmlelements.com/angular/demos/datetimepicker/overview/. You can also edit samples in Stackblitz.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/July 5, 2021 at 9:48 am #101978davoutMemberNowhere in those demos does it include a reference to a ‘DateTime’ class instance in the TS code – I’ve been through all of them!
So I will repeat my question, if I am including a reference to ‘DateTime’ what import statement does this require?July 5, 2021 at 10:09 am #101979adminKeymasterHi davout,
There is no import for Smart.Utilities.DateTime because it is not used anywhere. Such Typescript definition does not exist.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/July 5, 2021 at 10:28 am #101980davoutMemberSo how do I point to the source of the DateTime class in my TypeScript code?
July 5, 2021 at 10:32 am #101982adminKeymasterHi davout,
You do not need to use the DateTime class in order to use DatetimePicker. The examples clearly show how you can use the component and get/set dates to it. This class is internally used and for Angular it is not part of the public API.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/July 5, 2021 at 10:38 am #101983davoutMemberThat is not true – unless our docs are wrong!
The ‘DateTimePicker’ has a ‘value’ property that is an instance of DateTime
See: m https://www.htmlelements.com/angular/demos/datetimepicker/overview/#toc-value_anyJuly 5, 2021 at 10:52 am #101985adminKeymasterHi davout,
In future versions of the library, we will add a new Angular example of our DateTimePicker and expose additional API options. Again, Typescript definitions are not available for what you try to use. They do not exist.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/July 5, 2021 at 11:02 am #101986davoutMemberYour answer does not address my question…
I want to set a value against the DateTimePicker.value’ property, how is that done?July 5, 2021 at 11:11 am #101987adminKeymasterHi davout,
Your question was about a Typescript error and the answer is that such error is raised, because there is no such Typescript API. The DateTimePicker accepts Javascript Date object. You can set the ‘value’ prop to a Javascript date.
Best regards,
Peter Stoev
Smart UI Team
https://www.htmlelements.com/ -
AuthorPosts
- You must be logged in to reply to this topic.