【问题标题】:How to connect azure mobile services to ionic application如何将 Azure 移动服务连接到 ionic 应用程序
【发布时间】:2017-08-02 07:05:48
【问题描述】:

到目前为止,我已经创建了一个非常简单的带有登录名和用户名的 ionic 应用程序。我目前正在使用 Microsoft azure 移动服务来托管我的应用程序。但是我不知道如何使用 php 文件和服务器。我是使用服务器的初学者,在此先感谢您。

PHP 代码:

<?php
try {
    $conn = new PDO("microsoft azure connection string", "username", "password");
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
    print("Error connecting to SQL Server.");
    die(print_r($e));
}

?>

登录控制器:

 .controller('loginCtrl', ['$scope', '$stateParams', // The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
    // You can include any angular dependencies as parameters for this function
    // TIP: Access Route Parameters for your page via $stateParams.parameterName
    function ($scope, $stateParams) {

    $scope.User = {};
    $scope.login = function() {
    str="Dont know what to put here";
                $http.get(str)
                .success(function (response){  
          }).error(function() {                         //if login failed
                        var alertPopup = $ionicPopup.alert({
                            title: 'Login failed!',
                            template: 'Please check your credentials!'
                        });
                });
            };

    }])

登录html

<ion-view title="Login" id="page6">
  <ion-content padding="true" class="has-header">
    <form id="login-form4" class="list">
      <ion-list id="login-list2">
        <label class="item item-input" id="login-input10">
          <span class="input-label">Username/Email</span>
          <input type="text" ng-model="User.email" placeholder="">
        </label>
        <label class="item item-input" id="login-input11">
          <span class="input-label">Password</span>
          <input type="password" ng-model="User.password" placeholder="">
        </label>
      </ion-list>
      <div class="spacer" style="height: 40px;"></div>
      <a id="login-button2" ng-click="login()" class="button button-positive  button-block">Log in</a>
      <a ui-sref="signup" id="login-button3" class="button button-positive  button-block button-clear">Or create an account</a>
    </form>
  </ion-content>
</ion-view>

【问题讨论】:

    标签: javascript php html azure ionic-framework


    【解决方案1】:

    目前,为 ASP.NET 和 Node.js Web 应用程序提供了 Azure 应用服务移动应用 SDK。因此,您可以将后端切换到 Node.js 或 .NET 后端。

    然后您可以在您的移动后端创建Easy API/Custom API,然后您就可以将您的API 与invokeApi()Javascript Clients for Azure Mobile Apps 连接起来。

    更多信息请参考this blog post

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多