javascript - How load $http service app on startup in Ionic framework? -
javascript - How load $http service app on startup in Ionic framework? -
how load $http service app on startup in ionic framework?
// service
appmodule.factory('newgames', function($http, $ionicloading) { // json array var newgames = []; var request = {'searchstring' : 'name_fr'}; $http.get('http://example.com/rest/data.php', { cache: true}, request).success(function(response) { newgames = response; }); homecoming { all: function() { //$ionicloading.hide(); homecoming newgames; } } });
// controller
myapp.controller('mainctrl', function($scope, newgames, $ionicslideboxdelegate, $stateparams, $ionicplatform) { $scope.nextslide = function() { $ionicslideboxdelegate.next(); } $scope.newgames = newgames.all(); });
if press button, info loaded. how create info loaded @ startup?
use ionic.platform.ready()
method, documented here.
you can run method anywhere in app, may mill or controller.
javascript angularjs ionic-framework
Comments
Post a Comment