我得到下面的錯誤是我的AngularJs應用程序。undefined不是AngularJS中的函數錯誤
TypeError: undefined is not a function
at Scope.$rootScope.shareImageNow (index.controller.js:150)
我不知道做一些谷歌研究之後是什麼原因。
controller.js文件
app.controller('ViewCtrl', function($rootScope, $state, $scope, $ionicPlatform, $ionicPopup, $ionicLoading, $ionicSlideBoxDelegate, $ionicScrollDelegate, $timeout, Service) {
var appUrl = "https://play.google.com";
$rootScope.shareNow = function() {
var message = "xx";
var subject = "yy";
Service.share(message, subject, null, appUrl);
}
$rootScope.shareImageNow = function() {
var imageIndex = 0;
var imgUrl = $rootScope.itemData[imageIndex]['url'];
var message = "xx";
var subject = "yy";
Service.share(message, subject, imgUrl, appUrl);
}
});
service.js文件:
module.service('Service', function($rootScope, $ionicPlatform, $cordovaSocialSharing) {
$rootScope.share = function(message,subject,file,link) {
$ionicPlatform.ready(function() {
$cordovaSocialSharing
.share(message, subject,file,link);
}, false);
}
}
誤差以在controller.js文件中的下面劃線所示。
Service.share(message, subject, null, appUrl);
哪一個是在index.controller.js – 2015-02-05 17:53:09
對不起@DavidGrinberg線150得到的錯誤。我現在已經更新了這個問題。顯示的錯誤在Service.share(message,subject,null,appUrl); – Purus 2015-02-05 17:54:33