probably a newbie question.
I have a problem where my databinding in the HTML updates just fine, but the log_interval function always console log "3". I want to use the updated model "interval" to send a request to a timeseries database, with different intervals. But every time I'm sending just 3, even though my view is updating as it should.
I've tried with $scope.$watch (like in the snippet), but it only triggers when the page is loading. Also I tried with ng-change and ng-click, both in all the radio buttons respectively and in the element. I tried to call $scope.$watch, but I get an error saying $digest is already running. Nothing works :( How can I update my model in the controller, so that I can use it for different HTTP request?
.controller('DashCtrl', ['$scope', '$log', function($scope, $log) {
$scope.interval = 3;
$scope.$watch("interval", function() {
$log.log($scope.interval);
}, true);
$scope.log_interval = function() {
$log.log($scope.interval);
};
}])
;
<h1>{{interval}}</h1>
<div class="btn-group btn-group-justified">
<label class="btn btn-default" ng-model="interval" btn-radio="1" uncheckable>1 day</label>
<label class="btn btn-default" ng-model="interval" btn-radio="2" uncheckable>3 days</label>
<label class="btn btn-default" ng-model="interval" btn-radio="3" uncheckable>1 week</label>
<label class="btn btn-default" ng-model="interval" btn-radio="4" uncheckable>2 weeks</label>
<label class="btn btn-default" ng-model="interval" btn-radio="5" uncheckable>1 month</label>
<label class="btn btn-default" ng-model="interval" btn-radio="6" uncheckable>3 months</label>
</div>