Skip to content

Instantly share code, notes, and snippets.

@richfergus
Last active October 17, 2022 17:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richfergus/6c739b8100bf0cd1c6c7 to your computer and use it in GitHub Desktop.
Save richfergus/6c739b8100bf0cd1c6c7 to your computer and use it in GitHub Desktop.
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);
});
});
@richfergus
Copy link
Author

Used to fix the Coldfusion 9 JSON formating for two key.values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment