[英]Connect to Azure Mobile Services from dynamic HTML content in WebView
[英]How to connect azure mobile services to ionic application
到目前为止,我已经使用登录名和用户名创建了一个非常简单的离子应用程序。 我目前正在使用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>
当前,为ASP.NET和Node.js Web应用程序提供了Azure App Service移动应用程序SDK。 因此,您可以将后端切换到Node.js或.NET后端。
然后,您可以在移动后端中创建Easy API
/ Custom API
,并且可以将您的API与适用 于Azure移动应用的Javascript客户端的 invokeApi()连接起来。
有关更多信息,请参阅此博客文章 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.