Skip to content

Instantly share code, notes, and snippets.

@liorocks
Last active December 8, 2015 12:34
Show Gist options
  • Save liorocks/f2f17947dfebc68c9845 to your computer and use it in GitHub Desktop.
Save liorocks/f2f17947dfebc68c9845 to your computer and use it in GitHub Desktop.
Ionic

Global Loading Screen with Interceptors

var app = angular.module('ionicApp', ['ionic'])

app.config(function($httpProvider) {
  $httpProvider.interceptors.push(function($rootScope) {
    return {
      request: function(config) {
        $rootScope.$broadcast('loading:show')
        return config
      },
      response: function(response) {
        $rootScope.$broadcast('loading:hide')
        return response
      }
    }
  })
})

app.run(function($rootScope, $ionicLoading) {
  $rootScope.$on('loading:show', function() {
    $ionicLoading.show({template: 'foo'})
  })

  $rootScope.$on('loading:hide', function() {
    $ionicLoading.hide()
  })
})

app.controller('MainCtrl', function($http, $ionicLoading) {
  var _this = this

  $http.jsonp('http://api.openbeerdatabase.com/v1/breweries.json?callback=JSON_CALLBACK').then(function(result) {
    _this.breweries = result.data.breweries
  })
})

Source: http://learn.ionicframework.com/formulas/loading-screen-with-interceptors/

Fix Ionic iOS Emulator Splash Screen Stuck Issue

ionic platform rm ios
ionic platform ios
ionic build ios

Remove Splash Screen Loading Indicator

Add the following line of code into config.xml file:

<preference name="ShowSplashScreenSpinner" value="false" />

Source: http://stackoverflow.com/a/11762139/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment