我可以在离子视图

时间:2015-07-09 08:09:24

标签: android ios angularjs ionic-framework ionic

您好我想使用ionic view在设备上测试我的应用,但我的数据库位于另一台运行网络服务的电脑上。我想知道是否可以从ionic view连接到该服务。在我的浏览器上(ionic serve)我正在努力解决CORS问题,那就是在离子视图上运行时会出现同样的问题吗?

Html代码

<ion-view view-title="Dashboard">
    <ion-content class="padding">
        <div class="list card">
            <div class="item item-divider">Recent Updates</div>
            <div class="item item-body">
                <div>
                    <b>sector 3</b>
                </div>
            </div>
        </div>
        <div class="list card">
            <div class="item item-divider">Upcoming</div>
            <div class="item item-body">
                <p>{{Success + " " + Error}}</p>
            </div>
        </div>
    </ion-content>
</ion-view>

JavaScript代码

angular.module('starter.controllers', [])

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

    $http.get("http://192.168.1.108/TruckService.svc?singleWsdl")
        .success(function(data) {
            $scope.Success = "SUCCESS!";
        })
        .error(function(data) {
            $scope.Error = "ERROR dude!";
        });
})

.controller('ChatsCtrl', function($scope, Chats) {

    $scope.chats = Chats.all();
    $scope.remove = function(chat) {
        Chats.remove(chat);
    };
})

.controller('ChatDetailCtrl', function($scope, $stateParams, Chats) {
    $scope.chat = Chats.get($stateParams.chatId);
})

.controller('AccountCtrl', function($scope) {
    $scope.settings = {
        enableFriends: true
    };
});

0 个答案:

没有答案