I'm trying to pick up AngularJS with a ColdFusion back end and am running into a few roadblocks. I am modifying their "To Do" app http://angularjs.org/ with the CF Art Gallery database. I'm trying to link a ColdFusion CFC to an Angular app using AJAX.
Below is my artists.cfc:
<cfcomponent>
<cffunction name="getArtists" access="remote" >
<cfargument name="firstName" default="">
<cfargument name="lastName" default="">
<cfquery name="getArtists_sql" datasource="cfartgallery">
SELECT
firstname as text,
lastname as done
FROM artists
WHERE 0=0
<cfif firstName neq "">
AND ucase(firstname) like ucase('%#FIRSTNAME#%')
</cfif>
<cfif lastName neq "">
OR ucase(lastname) like ucase('%#LASTNAME#%')
</cfif>
</cfquery>
<cfreturn getArtists_sql>
</cffunction>
</cfcomponent>
I call the CFC using AngularJS with the following code:
function TodoCtrl($scope, $http) {
$http.get('cfc/artists.cfc?method=getArtists&returnformat=json').
success(function (response) {
$scope.todos = data.DATA;
}).
error(function (data) {
$scope.todos = data;
});
}
I know that I get a response back. Below is the JSON string Chrome's developer tools returns for me:
{
"COLUMNS":
["TEXT","DONE"],
"DATA":[
["Aiden","Donolan"],
["Austin","Weber"],
["Elicia","Kim"],
["Jeff","Baclawski"],
["Lori","Johnson"],
["Maxwell","Wilson"],
["Paul","Trani"],
["Raquel","Young"],
["Viata","Trenton"],
["Diane","Demo"],
["Anthony","Kunovic"],
["Ellery","Buntel"],
["Emma","Buntel"],
["Taylor Webb","Frazier"],
["Mike","Nimer"]
]}
This doesn't look like the notation Angular used in their demo:
[
{text:'learn angular', done:true},
{text:'build an angular app', done:false}
]
Can someone point me to the right direction as to how I can go about getting this to work properly? Ideally, I would like to keep the CFC intact so that in can be reused for a different application so the JSON manipulation would have to be done in the Javascript end.