ngCordova和socialsharing出错

时间:2016-04-12 04:29:38

标签: javascript angularjs cordova ionic-framework

错误:

Error: undefined is not an object (evaluating '$window.plugins.socialsharing')
canShareVia@

HTML:

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

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

控制器:

.controller('PlayCtrl', function($scope, $cordovaSocialSharing) {

  $scope.shareAnywhere = function() {
        $cordovaSocialSharing.share("This is your message", "This is your subject", "www/imagefile.png", "https://www.thepolyglotdeveloper.com");
  }

  $scope.shareViaTwitter = function(message, image, link) {
        $cordovaSocialSharing.canShareVia("twitter", message, image, link).then(function(result) {
            $cordovaSocialSharing.shareViaTwitter(message, image, link);
        }, function(error) {
            alert("Cannot share on Twitter");
        });
    }

})

app.js

angular.module('starter', ['ionic', 'starter.controllers', 'chart.js','ngCordova'])

所以我使用(sudo npm install g-cordova)安装了cordova并使用了凉亭来安装ng-cordova。我添加了socialshare插件,所有文件都位于我的离子应用程序文件目录的插件文件夹中。

我不了解我需要做的其他事情才能让它发挥作用:(

0 个答案:

没有答案