2016-03-26 30 views
2

我是移動開發的新手,並且努力嘗試使用Azure進行身份驗證。我正在使用Mac進行我的開發工作。我創建了基於sidemenu模板的Ionic項目,並在其中添加了插件「cordova-plugin-ms-adal」。爲了確保代碼正常工作,我添加了以下幾行來執行登錄方法。我收到錯誤 - 「VM370:1 Uncaught ReferenceError:Microsoft is not defined(...)科爾多瓦/ Ionic框架與ADAL合作

真心感謝您的幫助。

$scope.doLogin = function() { 
    console.log('Doing login', $scope.loginData); 


    var AuthenticationContext = new Microsoft.ADAL.AuthenticationContext("https://login.microsoftonline.com/abcinc.onmicrosoft.com"); 
    }; 

<!DOCTYPE html> 
<html> 
    <head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
    <title></title> 

    <link href="lib/ionic/css/ionic.css" rel="stylesheet"> 
    <link href="css/style.css" rel="stylesheet"> 

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above 
    <link href="css/ionic.app.css" rel="stylesheet"> 
    --> 

    <!-- ionic/angularjs js --> 
    <script src="lib/ionic/js/ionic.bundle.js"></script> 

    <!-- cordova script (this will be a 404 during development) --> 
    <script src="cordova.js"></script> 

    <!-- your app's js --> 
    <script src="js/app.js"></script> 
    <script src="js/controllers.js"></script> 
    </head> 

    <body ng-app="starter"> 
    <ion-nav-view></ion-nav-view> 
    </body> 
</html> 

回答

1

我不能發表評論,但 - 在回答中

我從頭開始創建一個離子標籤示例應用程序,因此

新增科爾多瓦 - 插件 - MS-阿達爾

添加導航按鈕到其中一個視圖

<ion-nav-buttons side="primary"> 
    <button class="button" ng-click="doLogin()"> 
     LOGIN 
    </button> 
</ion-nav-buttons> 

將doLogin方法添加到視圖的控制器

.controller('DashCtrl', function ($scope) { 
    $scope.doLogin = function() { 
     console.log('Doing login'); 
     var AuthenticationContext = new Microsoft.ADAL.AuthenticationContext("https://login.microsoftonline.com/abcinc.onmicrosoft.com"); 
    }; 
}) 

你有沒有這樣的方式?