1
我在我的Cordova/Ionic應用程序中使用了ngCordova。我得到這個錯誤信息建立之後:
Uncaught ReferenceError: $cordovaOauth is not defined
的index.html
app.js
此外,如果我點擊登錄按鈕
<div class="button button-block button-positive"ng-controller="modalController" ng-click="facebookLogin()">Facebook Login</div>
我會得到另一個錯誤消息。
錯誤
這就是功能位於
控制器
.controller('modalController', ['$scope', '$ionicModal', '$firebase', '$ionicHistory', '$state', '$cordovaOauth', '$localStorage', '$sessionStorage','$location', function ($scope, $ionicModal, $firebase, $ionicHistory, $state, $cordovaOauth, $localStorage, $sessionStorage, $location) {
$ionicModal.fromTemplateUrl('templates/register.html', {
scope: $scope,
animation: 'slide-in-up',
backdropClickToClose: false,
hardwareBackButtonClose: false,
focusFirstInput: true
}).then(function (modal) {
$scope.modal = modal;
});
$scope.$on('$ionicView.beforeEnter', function (event, viewData) {
viewData.enableBack = true;
console.log(viewData.enableBack);
});
$scope.goBack = function() {
$ionicHistory.goBack();
console.log("back pressed");
};
/*Notice that after a successful login, the access token is saved and we are redirected to our profile. The access token will be used in every future API request for the application.*/
$scope.facebookLogin = function() {
$cordovaOauth.facebook("1234", ["email", "read_stream", "user_website", "user_location", "user_relationships"]).then(function (result) {
$localStorage.accessToken = result.access_token;
$location.path("/profile");
}, function (error) {
alert("There was a problem signing in! See the console for logs");
console.log(error);
});
};
我不明白這個錯誤,所有的文件都在的地方,我做了所有注射。我在這裏錯過了什麼?
你需要在運行函數注入科爾多瓦AUTH太 –
你參考angular.js文件? – Sajeetharan
@AmmarAjmal我在.run函數中注入了'$ cordovaOauth',它將錯誤減少爲1(謝謝)。我仍然得到這個錯誤,雖然'未捕獲的錯誤:[$注射器:unpr]未知的提供者:$ cordovaOauthProvider < - $ cordovaOauth' Sajeetharan我已經通過'' –