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