Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49169

I am trying to to make an app to load data from mysql database in android app. But when i running the app using ionic serve --lab it's work correctly on browser but not working on mobile

$
0
0

@Sherbadshah wrote:

var host = 'http://' + store.get("host") + '/easyway/';

angular.module('starter.controllers', [])
.controller('MenuCtrl', function($scope, $ionicModal, $timeout) {
$scope.exit = function() {
if (confirm("Are you want to exit the app ?")) {
ionic.Platform.exitApp();
}
}
})
///////////////////////Home controller /////////////////////////////////////

.controller('HomeCtrl', function($scope, $http) {

////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////// checking online status and host ////////////////////////////////////////////////
////////////////////////////////////////////////// // //////////////////////////////////////////////////////
$http.get(host + '/api/zubair/api.php?online')
    .then(
        function(e) {
            console.log(e);
            if (!e.data) {
                var input = prompt("Unknown host please enter host name");
                store.set("host", input);
                host = 'http://' + input + '/easyway/';
            }
        },
        function(e) {
            var input = prompt("Unknown host please enter host name");
            store.set("host", input);
            host = 'http://' + input + '/easyway/';
        }
    );

})

/////////////////////Order controller ///////////////////////////////////

.controller('OrdersCtrl', function($scope, $http) {

    ////////////////////////////////Displaying Records From Database///////////////////////////////////////////////////////


    $http.get('http://localhost/api/zubair/api.php')
        .then(function(response) {
            $scope.names = response.data.records;

            ////////////////////////////////Search ////////////////////////////////////////////////////////////////////////////////

            $scope.search = '';

            ///////////////////////////////Sending SMS ////////////////////////////////////////////////////////////////////////////


            $scope.send_sms = function() {
                // alert(no);
                var options = {
                    replaceLineBreaks: false,
                    android: {
                        intent: ''
                    }
                };

                var msg = prompt("Enter text msg");
                $cordovaSms
                sms.send("03059084920", msg, options, function() {
                    alert("Success");
                }, function(err) {
                    alert("Error");
                });

            }
        })
})
.controller('HelpCtrl', function($scope, $stateParams) {})
.controller('AboutCtrl', function($scope, $stateParams) {});

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 49169

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>