• Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

    ng-init for date.to and date.from

    Dashboard Designer & Custom AngularJS Pages
    3
    3
    622
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Phillip Weeks last edited by Phillip Weeks

      I would like to hard code the date.to and date.from on my dashboard. Not sure how to initially set with ng-init the date.from to Date("2019-01-01") and date.to Date("2019-12-01") ?

      1 Reply Last reply Reply Quote 0
      • ThomasEinasto
        ThomasEinasto last edited by ThomasEinasto

        Hi @Phillip-Weeks ,

        One can create a new usermodule component to handle like ng-init.

        userModule.component('gettime', {
            bindings:{
                timestampIn: '@?',
                tsFormat: '@?',
                newDateo: '=?',
                newDates: '=?'
            },
            controller:['$scope',
                function($scope){
        
                    $scope.$watch('$ctrl.timestampIn', () => {
        
                        let dateobject = moment(this.timestampIn);
                        
                        let datestring = moment(this.timestampIn).format(this.tsFormat);
                        
                        if (typeof this.timestampIn !== "undefined"){
                            
                                this.newDateo = dateobject;
                                this.newDates = datestring;
                                
                                //console.log(typeof(this.newDateo)); << returns dateobject
                                //console.log(typeof(this.newDates)); << returns string
                        }
                        
                    }, true);
                
                
            }]
            
        });
        
        

        new-dateo is date object which you should be able to use as your date.from / date.to variable.
        new-dates is date string which is formatted like you want based on momentjs format function.

        Usage in dashboard:

        <gettime timestamp-in="10/05/2019 22:10:10" ts-format="DD/MM/YYYY HH:mm:ss" new-dateo="js" new-dates="jss"></gettime>
        
        {{js}}
        <br>
        {{jss}}
        

        Result in dashboard:

        Sat Oct 05 2019 22:10:10 GMT+0300
        05/10/2019 22:10:10
        
        1 Reply Last reply Reply Quote 1
        • Jared Wiltshire
          Jared Wiltshire last edited by

          <div ng-init="dateBar.from = ('2019-12-08T09:16:47.297' | maMoment:'toDate')"></div>
          

          Developer at Radix IoT

          1 Reply Last reply Reply Quote 0
          • First post
            Last post