Message Displayed On Ionic Lab But Does Not Display On ios Emulator Or Simulator

In my app I extract messages from a local php file to display on the screen using $http.get(). The messages display fine in Ionic lab’s preview but when I build the app for ios and open it in the simulator or on Ionic View on my phone the message does not show. Does anyone know how to fix this?

Javascript:

myapp.controller('firstcontroller', function ($scope, $http, $ionicModal, $timeout){
 
$http.get("js/testfile.php")
.success(function(data) {
  $scope.names1 = data.records;
  $scope.names =  $scope.names1;
            })
            .error(function(data) {
                alert("ERROR");
            });
 })

HTML:

    <ion-content>
    <p class="quote">&quot;{{names[2].Name}}&quot;</p>
    <p class="author">- {{names[2].City}}</p>
    </ion-content>

What’s the point of getting a local php file on your phone, it isn’t interpreted by PHP as there is no web server to do so.
When you run your app in browser your PHP is served by your web server and interpreted.

So if you want to make it work your GET request must be to your server URL not a local URL.

If you use remote debugging from your MAC connected to your device via USB, you’ll see the error.

1 Like