JavaScript UI Libraries & Blazor Components Suite – Smart UI Forums Date & Time Pickers Typescript compile error Smart.Utilities.DateTime

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #101969
    davout
    Member

    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 compiled

    import {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()));
    

     

    #101972
    admin
    Keymaster

    Hi 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/

    #101974
    davout
    Member

    Ok, so what ‘import’ and class name should be used in the TS file?

    #101975
    admin
    Keymaster

    Hi 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/

    #101978
    davout
    Member

    Nowhere 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?

    #101979
    admin
    Keymaster

    Hi 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/

    #101980
    davout
    Member

    So how do I point to the source of the DateTime class in my TypeScript code?

    #101982
    admin
    Keymaster

    Hi 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/

    #101983
    davout
    Member

    That 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_any

    #101985
    admin
    Keymaster

    Hi 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/

    #101986
    davout
    Member

    Your answer does not address my question…
    I want to set a value against the DateTimePicker.value’ property, how is that done?

    #101987
    admin
    Keymaster

    Hi 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/

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.