I have built a simple ionic app to test my api. But I ran into problem because when I run it in live-reload mode (-l option) everything works just fine (ionic run ios -l). But when I did not use live-reload (ionic run ios), it is seems that my app got an error. I cannot debug where my apps went wrong because that require live-reload option which an error won't occur.
I have reinstall the whitelist plugins several times. I added the below line into my config.xml inside widget zone.
<access origin="*"/>
<allow-intent href="*"/>
<allow-navigation href="*"/>
and also the below line in inside my index.html
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
this is my controller code
var url="/api/event/new"
.controller('Test', function($http, $scope) {
$http.get(url).then(function(data) {
$scope.allEvents = {
all : function() {
return data.data;
},
remove: function(Events) {
data.data.splice(data.data.indexOf(Events), 1);
},
get : function(_id) {
for (var x in data.data) {
if(data.data[i]._id == _id) {
return data.data[i];
}
}
return null;
}
};
$scope.isNotConnected = false;
}, function(error) {
$scope.allEvents = {
all : function() {
return [{"title" : "Connection error!"}];
}
}
$scope.isNotConnected = true;
console.log(error);
});
})
This is my ionic info
Cordova CLI: 6.1.1
Ionic Framework Version: 1.3.1
Ionic CLI Version: 1.7.15
Ionic App Lib Version: 0.7.2
ios-deploy version: 1.8.6
ios-sim version: 5.0.8
OS: Mac OS X El Capitan
Node Version: v5.9.1
Xcode version: Xcode 7.3 Build version 7D175
/api/event/new
, but that doesn't really tell the app where to go. It sounds like you'll need to specifically tell the controller the hostname of the server – Jaron Thatcher