You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Static allocation
$scope.enabled = data.enabled; //"false" or "true"
$scope.onOff = data.onOff; //"false" or "true"
$scope.yesNo = data.yesNo; //"false" or "true"
$scope.disabled = data.disabled; //"false" or "true"
//I receive so many values from API call like this.
//I allocate all params dynamically, Because of this data assigned to $scope.enabled param is "true"(String) not true(boolean).
//I have a generic code to assign Api values in scope and perform operations on API values, but now only for this switch I have to check received value and after that I have to proceed, code will be like
if(data.enabled == "true")
$scope.enabled = true
else
$scope.enabled = false
})
$scope.changeCallback = function() {
console.log('This is the state of my model ' + $scope.enabled);
};
});
May be I think its not an issue but this implementation will helps all.
The text was updated successfully, but these errors were encountered:
hmudimi
changed the title
While passing data recieved from an API call, switch on/off not working as expected (While passing "true" and "false"[string])
While passing data recieved from an API call, switch on/off not working as expected (While passing "true" and "false"[string values])
May 30, 2016
angular.module('app', ['uiSwitch'])
.controller('MyController', function($scope) {
$http.get("myurl").success(function (data, status, headers, config) {
//Static allocation
$scope.enabled = data.enabled; //"false" or "true"
$scope.onOff = data.onOff; //"false" or "true"
$scope.yesNo = data.yesNo; //"false" or "true"
$scope.disabled = data.disabled; //"false" or "true"
//I receive so many values from API call like this.
//I allocate all params dynamically, Because of this data assigned to $scope.enabled param is "true"(String) not true(boolean).
//I have a generic code to assign Api values in scope and perform operations on API values, but now only for this switch I have to check received value and after that I have to proceed, code will be like
if(data.enabled == "true")
$scope.enabled = true
else
$scope.enabled = false
})
$scope.changeCallback = function() {
console.log('This is the state of my model ' + $scope.enabled);
};
});
May be I think its not an issue but this implementation will helps all.
The text was updated successfully, but these errors were encountered: