I am new to AngularJS. I have a .net MVC WebAPI Restful app running on a IIS server. When I query the api with http://xxx.xxx.xxx.xxx/api/project I get:
[{"Id":1,"Name":"Glenn Block","Created":"0001-01-01T00:00:00"},{"Id":2,"Name":"Dan Roth","Created":"0001-01-01T00:00:00"}]
I created a ProjectCtrl (in a separate empty project) that looks like this:
angular.module('Project', ['ngResource']);
function ProjectCtrl($scope, $resource) {
$scope.project = $resource('http://192.168.1.221/api/project'
);
$scope.project.get(function (data) {
console.log('success, got data: ', data);
}, function (err) {
alert('request failed');
});
}
I always get a failure. I addressed CORS issues on the server and the request header contains
Access-Control-Request-He... x-requested-with
Access-Control-Request-Me... GET
What I find odd is that when I look in firebug it does NOT do a get but rather shows Option project with a status of 200
I am not sure what I missing.
getneed to be an empty{}object? If so, you(err)callback is actually your returned data. Just a guess.