2017-05-30 4 views
0

Ich bin Ionic v1 und habe ein Problem. Es gibt viele Schlagzeilen zu diesem Fehler. Aber ich kann keine Lösung für mich finden.Ionic Web Service jedes Mal, wenn die Seite geöffnet wird

ich tun,

<ion-nav-view name="other" cache-view="false"></ion-nav-view> 

und

$stateProvider.state('app', { 
    url: '/app', 
    cache: false, 
    abstract: true, 
    templateUrl: 'templates/menu.html', 
    controller: 'AppCtrl' 
}) 

Run Controller die Seite jedes Mal geöffnet wird. Aber meine Web-Service-Code nur ausgeführt werden, wenn erste

geöffnet

Mein Code:

.controller('PlaylistsCtrl', function($scope, $rootScope, $http, $ionicPopup) { 

    $scope.loadingShow(); 

    console.log("Test"); //Run everytime but $http run only first opened 

    $http.get($scope.webServiceUrl + "json_getSharedPicture.php") 
     .then(function(response) { 
      $scope.loadingHide(); 
      $rootScope.playlists = response.data; 
     }); 

}) 

Meine Ionic Info:

global packages: 

    @ionic/cli-utils : 1.2.0 
    Cordova CLI  : 7.0.1 
    Ionic CLI  : 3.2.0 

local packages: 

    @ionic/cli-plugin-cordova : 1.2.1 
    @ionic/cli-plugin-ionic1 : 1.2.0 
    Cordova Platforms   : android 6.2.3 ios 4.4.0 
    Ionic Framework   : ionic1 1.3.3 

System: 

    Node  : v6.10.3 
    OS   : Windows 10 
    Xcode  : not installed 
    ios-deploy : not installed 
    ios-sim : not installed 

Antwort

1
If you want to hit your code every time you load that page. 

Sie benötigen eine Funktion zu initialisieren und nennen es

function onLoad() { 
$http.get($scope.webServiceUrl + "json_getSharedPicture.php") 
    .then(function(response) { 
     $scope.loadingHide(); 
     $rootScope.playlists = response.data; 
    }); 
}onLoad(); 
Verwandte Themen