0

我正在开发离子移动应用程序。我已经按照这些文件https://github.com/azure/azure-mobile-apps-js-clienthttps://github.com/azure-appservice-samples/ContosoMoments/tree/master/src使用Azure移动应用程序时出错 - Javascript客户端SDK

当我在我的控制器中注入'mobileServicesClient'时,出现未知提供者错误。 如果我在功能上直接使用这样

var clientRef = new MobileServiceClient('https://******.azurewebsites.net'); 
clientRef.login('aad').then(function(result){ console.log(result); },function(result){ console.log(result); } 

我得到错误:“MobileServiceClient没有定义”

回答

0

当你正在使用离子框架来实现客户端应用程序,你可以尝试使用Apache Cordova plugin for Azure Mobile Apps作为客户端SDK。

尤其对于基于离子的应用,您可以参考https://github.com/Microsoft/azure-mobile-apps-with-ionic,了解具有离子的azure移动应用的入门示例项目。

任何进一步的关注,请随时让我知道。

+0

使用适用于Azure移动应用程序的Apache Cordova插件,我能够进行身份验证。我还为JavaScript SDK及其工作找到了此https://ajax.aspnetcdn.com/ajax/mobileservices/MobileServices.Web-1.2.7.min.js。我想要构建混合移动应用程序。那么JavaScript SDK会更好还是客户端SDK? – devangi

+0

对于H5应用程序,使用JS SDK以及移动应用程序,建议使用客户端SDK。正如您可以在https://github.com/Azure/azure-mobile-apps-js-client/tree/master/sdk/上所见,将SDK分成两个平台('web'&'cordova') SRC /平台。所以在认证和表操作中几乎是一样的,但应该是一些特殊的平台。 –

+0

对于Cordova应用程序,您可以参考https://docs.microsoft.com/zh-CN/azure/app-service-mobile/app-service-mobile-cordova-how-to-use-client-library,以及对于H5应用程序,您可以参考https://docs.microsoft.com/zh-cn/azure/app-service-mobile/app-service-mobile-html-how-to-use-client-library –

1

使用它之前你的对象添加脚本引用。

<script src="https://zumo.blob.core.windows.net/sdk/azure-mobile-apps-client.2.0.0-rc1.js"></script> 

并使用正确的名称空间

var clientRef = new WindowsAzure.MobileServiceClient('https://...'); 
+0

我也尝试过使用WindowsAzure。但它给出相同的错误WindowsAzure没有定义。我使用了azure-mobile-apps-client.js而不是azure-mobile-apps-client.2.0.0-rc1.js。他们之间有什么区别吗?在github上,我发现它(不是2.0.0)是最新的。 – devangi

+0

似乎这个lib还没有发布。在npm'npm show azure-mobile-apps-client version'中看到lib版本 - 它只显示* 2.0.0-rc1 *现在可用。所以看起来你不能使用严格的'2.0.0'。 – VadimB

+0

除了来自@VadimB的优秀评论之外,您还必须在加载页面之后才能引用MobileServiceClient。 - 我不是Ionic专家,但我相信在$ ionicPlatform.ready()的回调中引用是合适的。 –

相关问题