-1
我想在iPad上使用ionic
和插件上傳多張圖片。如何使用離子和科爾多瓦插件從i pad gallery上載多個圖像?
我正在一個錯誤:
Uncaught Error: [$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module ngCordova due to:
Error: [$injector:nomod] Module 'ngCordova' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
我沒有得到如何準確使用該插件+如何測試是否其工作或沒有?
app.js:
var app = angular.module('starter', ['ionic','ngCordova']);
app.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
});
app.controller('ImagePickerController', function($scope, $cordovaImagePicker, $ionicPlatform, $cordovaContacts) {
$scope.collection = {
selectedImage : ''
};
$ionicPlatform.ready(function() {
$scope.getImageSaveContact = function() {
// Image picker will load images according to these settings
var options = {
maximumImagesCount: 1, // Max number of selected images, I'm using only one for this example
width: 800,
height: 800,
quality: 80 // Higher is better
};
$cordovaImagePicker.getPictures(options).then(function (results) {
// Loop through acquired images
for (var i = 0; i < results.length; i++) {
$scope.collection.selectedImage = results[i]; // We loading only one image so we can use it like this
window.plugins.Base64.encodeFile($scope.collection.selectedImage, function(base64){ // Encode URI to Base64 needed for contacts plugin
$scope.collection.selectedImage = base64;
$scope.addContact(); // Save contact
});
}
}, function(error) {
console.log('Error: ' + JSON.stringify(error)); // In case of error
});
};
});
這是我在plunker代碼。
如果您安裝了正確的[ngCordova](http://ngcordova.com/docs/install/)插件,然後在** index.html **中添加了** ng-cordova.js **腳本,那麼首先您檢查。 –
我已經安裝了ng-cordova插件,並且包含它也 – Anky
你在瀏覽器或應用程序中嘗試的地方。 –