Angular: Empty Fiddle
http://angularjs.org/
by provegard
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
<p>Result: {{ result }}</p>
<div ng-bind="data"></div>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
myApp.config(["$provide", "$httpProvider", function($provide, $httpProvider) {
$provide.factory("authInterceptor", function($q) {
return function(promise) {
return promise.then(function(response) {
return response;
}, function(response) {
return $q.reject(response);
});
};
});
return $httpProvider.responseInterceptors.push("authInterceptor");
}
]);
function MyCtrl($scope, $http) {
var http = $http({method: "GET", url: "/foo"});
http.success(function(data, status) {
$scope.result = "OK: " + status;
$scope.data = data;
});
http.error(function(data, status) {
$scope.result = "ERROR: " + status;
$scope.data = data;
});
}