Skip to content Skip to sidebar Skip to footer

Angularjs - Input[type=range] Value Not Updated

I'm having a weird problem with input type range. The value is not updated even if I force change it. I'm using ionic 1 with angular I got a list of buttons with dates and a input

Solution 1:

Try to use

$scope.minTimeStep = timeobj.decimal;

instead of

$scope.data.minTimeStep = timeobj.decimal;

the nested object is causing the problem. Just remove data from you javascript and html.

Solution 2:

i did a hack. I just force update it in a $timer function. I don't know why. but it works for me.

$scope.updateTimeRange = function (selectedDate) {

    var timeobj = _getMinTime(selectedDate); //function to get minimum time for the selected date//updating the scopes but it does not work
    $scope.data.minTimeStep = timeobj.decimal;
    $scope.data.timeStep = timeobj.decimal;
    $scope.data.time = timeobj.time;

    //tried force update in the timer
    $timeout(function () {
        console.log('timeout value: '+document.querySelector('#time').value);
        document.querySelector('#time').value = timeobj.decimal;
    });

    console.log(timeobj);
    console.log($scope.data);
    console.log(document.querySelector('#time').value); 
}

Post a Comment for "Angularjs - Input[type=range] Value Not Updated"