我想使用相機插件和離子文件上傳方式拍照。但是,當我點擊按鈕時,它不起作用。我看着控制檯,沒有錯誤。相機插件無法在離子狀態下工作
查看:
<button class="button button-full button-assertive" ng-click="takePhoto">Take Photo</button>
<button class="button button-full button-assertive" ng-click="choosePhoto">Choose Photo</button>
<img ng-src="{{user.picture}}">
應用:
angular.module('starter', ['ionic','ngCordova'])
.controller('MainController', ['Camera', function($scope, Camera){
$scope.getPicture = function(options){
var options = {
quality : 75,
targetWidth : 200,
targetHeight : 200,
sourceType : 0
};
Camera.getPicture(options).then(function(imageData){
$scope.picture = imageData;
}, function(err){
console.log(err);
});
};
$scope.takePicture = function(options){
var options = {
quality : 75,
targetWidth: 200,
targetHeight: 200,
sourceType: 1
};
Camera.getPicture(options).then(function(imageData){
$scope.picture = imageData;
}, function(err){
console.log(err);
});
}
}])
.factory('Camera', function($q){
return {
getPicture: function(options) {
var q = $q.defer();
navigator.camera.getPicture(function(result) {
q.resolve(result);
}, function(err) {
q.reject(err);
}, options);
return q.promise;
}
}
})
所有幫助表示讚賞。 我是新手。