Skip to content

Instantly share code, notes, and snippets.

@zarko-tg
Created September 11, 2015 08:59
Show Gist options
  • Save zarko-tg/e62eb881cdf86b5c0ac0 to your computer and use it in GitHub Desktop.
Save zarko-tg/e62eb881cdf86b5c0ac0 to your computer and use it in GitHub Desktop.
Small Ionic http test
// Ionic Starter App
// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic'])
.run(function($ionicPlatform, $http) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
// No need for timeout really but just wait 5 second before making the call
setTimeout( function () {
$http.get('http://httpbin.org/get').
then(function(response) {
// this callback will be called asynchronously
// when the response is available
alert('ok');
}, function(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
alert('not ok ');
console.log( 'response', response );
});
}, 5000 );
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment