1

このプラグインを使用したい: $cordovaSocialSharingは、Ionic のネイティブ ソーシャル ボタン用に見つけた唯一のプラグインなので...

Chrome コンソールでコードを実行すると、次のエラーが表示されます: "未定義のプロパティ 'socialsharing' を読み取れません" @ (ng-cordova.js:6715)

ngcordova.com に記載されているように ng-Cordova とプラグインを何度も再インストールしましたが、機能しないようです... Android エミュレーターで試しましたが、どちらも機能しません。

ここに私のコード: 私の controllers.js:

angular.module('starter.controllers', ['ionic', 'ionic-ratings', 'onezone-datepicker', 'ngCordova'])

それから、

.controller('CaravanDetailCtrl', function($rootScope, $scope, $cordovaSocialSharing, sweetAlert) {
   $scope.socialsharingFacebook = function() {

            $cordovaSocialSharing
                .shareViaFacebook("msg", "img", "url")
                .then(function(result) {
                    SweetAlert.swal({   
                        title: "",   
                        text: "success",   
                        type: "success",   
                        showCancelButton: false,   
                        confirmButtonColor: "rgba(5, 60, 84, 0.8)",   
                        confirmButtonText: "OK",   
                        closeOnConfirm: true 
                    });
                }, function(err) {
                    SweetAlert.swal({   
                        title: "",   
                        text: "sorry",   
                        type: "error",   
                        showCancelButton: false,   
                        confirmButtonColor: "rgba(5, 60, 84, 0.8)",   
                        confirmButtonText: "OK",   
                        closeOnConfirm: true 
                    });
                });
    }

}

私もこれを試しました(controllers.jsで):

$ionicPlatform.ready(function() {
   $cordovaSocialSharing
            .shareViaFacebook("msg", "img", "url")
            .then(function(result) {
                SweetAlert.swal({   
                    title: "",   
                    text: "success",   
                    type: "success",   
                    showCancelButton: false,   
                    confirmButtonColor: "rgba(5, 60, 84, 0.8)",   
                    confirmButtonText: "OK",   
                    closeOnConfirm: true 
                });
            }, function(err) {
                SweetAlert.swal({   
                    title: "",   
                    text: "sorry",   
                    type: "error",   
                    showCancelButton: false,   
                    confirmButtonColor: "rgba(5, 60, 84, 0.8)",   
                    confirmButtonText: "OK",   
                    closeOnConfirm: true 
                });
            });
}

これを解決する方法、または実際に Ionic で動作する別のプラグインのアイデアはありますか?

4

1 に答える 1