我想使用这个插件:$cordovaSocialSharing,因为它是我为 Ionic 上的原生社交按钮找到的唯一插件......
在 Chrome 控制台中运行代码时出现此错误:“无法读取未定义的属性 'socialsharing'”@ (ng-cordova.js:6715)
我多次重新安装了 ng-Cordova,正如 ngcordova.com 和插件中所说的那样,但它似乎不起作用......我在 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 的插件的想法吗?