Last active
August 29, 2015 14:08
-
-
Save MikeBild/8db7431d3fe74784fb7d to your computer and use it in GitHub Desktop.
AngularJS tryGet(url)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html data-ng-app="myApp"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Try Get</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0-beta.13/angular.min.js"></script> | |
</head> | |
<body data-ng-controller="demoCtrl"> | |
<script> | |
angular | |
.module('myApp',[]) | |
.controller('demoCtrl', function($http, $q){ | |
$http.get('http://foobar1234.de') | |
.catch(function(data){ | |
return $http.get('http://foobar1234.de'); | |
}) | |
.catch(function(){ | |
return $http.get('http://www.google.de'); | |
}) | |
.catch(function(){ | |
return $http.get('http://foobar1234.de'); | |
}) | |
.then(function(data){ | |
console.log(data.status); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment