Last active
October 17, 2022 17:59
-
-
Save richfergus/6c739b8100bf0cd1c6c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myURL = 'myCfc.cfc?method=getItemsFromDb'; | |
var app = angular.module('angularOutput',[]); | |
app.controller("sectionController", function($scope, $http) { | |
$http.get(myURL). | |
success(function(data, status, headers, config) { | |
var log = []; | |
var output = ''; | |
angular.forEach(data.DATA, function(value, key) { | |
this.push(output +='{"value": '); | |
this.push(output += '"'+value[0]+'"'); | |
this.push(output +=',"text":'); | |
this.push(output += '"'+value[1]+'"'); | |
this.push(output +='}'); | |
this.push(output +=','); | |
}, log); | |
output = output.replace(/,\s*$/, "");/*had to remove the final comma */ | |
output = '['+output+']'; /*had to add the [] to corectally form the output*/ | |
$scope.sections = angular.fromJson(output); | |
}). | |
error(function(data, status, headers, config) { | |
console.log(data); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used to fix the Coldfusion 9 JSON formating for two key.values