0
votes

I have implemented the small mobile application in Cordova (VS2015). In my application I'm getting all the required data using asp.net wep api. My mobile solution working fine in ripple emulator. But not working in device mode (Andorid). I have published my web service and local IIS server and I use local IP address and port no to access it. Also I have enable cross domain call in my web api too.

bellow is my app.js find and service That I have implement using angularJS.

var app = angular.module('RandBApp', ['ionic', 'RandBApp.controllers'])

.run(function ($ionicPlatform) { $ionicPlatform.ready(function () { if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); } if (window.StatusBar) { StatusBar.styleDefault(); } }); })

.config(function ($compileProvider, $stateProvider, $urlRouterProvider, $httpProvider) {

$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|ghttps?|ms-appx|x-wmapp0):/);
$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|ms-appx|x-wmapp0):|data:image\//);

$stateProvider

.state('app', {
    url: "/app",
    abstract: true,
    templateUrl: "app/views/menu.html",
    controller: 'RandBAppCtrl'
})

.state('app.products', {
    url: "/products",
    cache: false,
    views: {
        'menuContent': {
            templateUrl: "app/views/products.html",
            controller: 'ProductsCtrl'
        }
    }
})

.state('app.productdetail', {
    url: "/products/:productid",
    views: {
        'menuContent': {
            templateUrl: "app/views/productdetail.html",
            controller: 'ProductDetailCtrl'
        }
    }
})

.state('app.signup', {
    url: "/signup",
    cache: false,
    views: {
        'menuContent': {
            templateUrl: "app/views/signup.html",
            controller: 'SignUpCtrl'
        }
    }
})

  .state('app.reservations', {
      url: "/reservations",
      cache: false,
      views: {
          'menuContent': {
              templateUrl: "app/views/reservations.html",
              controller: 'ReservationsCtrl'
          }
      }
  })

.state('app.reservationdetail', {
    url: "/reservations/:reservationid",
    views: {
        'menuContent': {
            templateUrl: "app/views/reservationdetail.html",
            controller: 'ReservationDetailCtrl'
        }
    }
})

.state('app.orders', {
    url: "/orders",
    cache: false,
    views: {
        'menuContent': {
            templateUrl: "app/views/orders.html",
            controller: 'OrdersCtrl'
        }
    }
})

.state('app.orderdetail', {
    url: "/orders/:orderid",
    views: {
        'menuContent': {
            templateUrl: "app/views/orderdetail.html",
            controller: 'OrderDetailCtrl'
        }
    }
})

    .state('app.loyaltyhistory', {
        url: "/loyaltyhistory",
        cache: false,
        views: {
            'menuContent': {
                templateUrl: "app/views/loyaltyhistory.html",
                controller: 'LoyaltyHistoryCtrl'
            }
        }
    })

.state('app.notifications', {
    url: "/notifications",
    cache: false,
    views: {
        'menuContent': {
            templateUrl: "app/views/notifications.html",
            controller: 'NotificationsCtrl'
        }
    }
});



$urlRouterProvider.otherwise('/app/products');

});

var serviceUrl = 'http://localhost:6787/';

app.constant('ngAuthSettings', { apiServiceBaseUri: serviceUrl, clientId: 'ngAuthApp', loginCredentail: 'loginCredentail' });

Here is my Service

app.factory('loyaltyservice', ['$http', '$q', '$log', 'ngAuthSettings', function ($http, $q, $log, ngAuthSettings) {

var loyaltyFactory = {};
var webAPIbase = ngAuthSettings.apiServiceBaseUri;
var loginCredentailKey = ngAuthSettings.loginCredentail;

var getLoyaltyTransactionDetails = function (userId) {

    var deferred = $q.defer();

    $http({
        method: 'GET',
        url: webAPIbase + "api/Loyalty/GetLoyaltyTransactionDetails",
        params: {
            userId: userId
        }
    }).success(function (response) {

        deferred.resolve(response);

    }).error(function (err, status, header, config) {

        deferred.reject(err);
    });

    return deferred.promise;

};

loyaltyFactory.getLoyaltyTransactionDetails = getLoyaltyTransactionDetails;

return loyaltyFactory;

}]);

Any Help really appreciate.

1

1 Answers

1
votes

Sorry Guys. I forgot to enable to port in firewall. After enabaling it is started to work.