Angularjs 每次打开页面时都会运行Ionic web服务
我正在使用Ionic v1,但有一个问题。关于这个错误有很多标题。但我找不到解决办法 是的 每次打开页面时运行控制器。但我的web服务代码只在第一次打开时运行 我的代码:Angularjs 每次打开页面时都会运行Ionic web服务,angularjs,node.js,ionic-framework,Angularjs,Node.js,Ionic Framework,我正在使用Ionic v1,但有一个问题。关于这个错误有很多标题。但我找不到解决办法 是的 每次打开页面时运行控制器。但我的web服务代码只在第一次打开时运行 我的代码: .controller('PlaylistsCtrl', function($scope, $rootScope, $http, $ionicPopup) { $scope.loadingShow(); console.log("Test"); //Run everytime but $http run o
.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;
});
})
我的爱奥尼亚信息:
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
您需要初始化一个函数并调用它
.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;
});
})
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
If you want to hit your code every time you load that page.
function onLoad() {
$http.get($scope.webServiceUrl + "json_getSharedPicture.php")
.then(function(response) {
$scope.loadingHide();
$rootScope.playlists = response.data;
});
}onLoad();