ngResource error handling (no CORS)
examples/angular/resource_v1_get.html
<script src="angular.min.js"></script> <script src="angular-resource.min.js"></script> <script src="resource_v1_get.js"></script> <div ng-app="DemoApp" ng-controller="DemoController"> {{res.text}} <hr> <div ng-show="error">Error! Check the console.</div> </div>
examples/angular/resource_v1_get.js
angular.module("DemoApp", ["ngResource"]) .controller("DemoController", ['$scope', '$resource', function($scope, $resource) { var Greeting = $resource('http://127.0.0.1:3000/api/v1/greeting'); $scope.res = Greeting.get( function(){}, function(resp) { console.log('error'); console.log(resp); $scope.error = true; } ); }]);