0
我正在嘗試實現Cordova相機插件,以允許用戶使用我現有的Cordova/AngularJS移動應用程序使用相機拍照。未定義相機
我想用這篇文章中找到的方法(這工作得很好了新的新鮮科爾多瓦應用程序) http://sourcefreeze.com/cordova-camera-plugin-example-using-ionic-framework/
我已經加入了ngCordova.min.js gruntfile,增加了該文件的應用程序當它通過gulp構建過程時。
內app.js我已經添加了模塊如下(請注意我還沒有添加由於整個app.js到它的長度)
// app.js
var hqApp = angular.module('hqApp', [ 'hqControllers', 'hqFilters', 'hqServices', 'hqDirectives',
'ngMaterial', 'ngCordova' ]); // ngCordova has been added to the array
// HTML視圖
<button class="button button-full" ng-click="uploadFromCamera()">
Take Photo
</button>
<img ng-show="imgURI !== undefined" ng-src="{{imgURI}}" style="text-align: center">
//控制器(不是整個控制器由於長度)
hqControllers.controller(
'PostController',
['$http', '$localStorage', '$location', '$modal', '$routeParams', '$rootScope', '$scope', '$timeout', 'Upload', '$window', 'CharacterCountFilterFilter', 'ApplicationService', function(ApiService, ConfirmDialog, ContentReview, FeedService, $http, $localStorage, $location, $modal, $q, $routeParams, $rootScope, $scope, snackbar, $timeout, Upload, $window, CharacterCountFilterFilter, ApplicationService, $cordovaCamera) {
// when button click hits this function
$scope.uploadFromCamera = function() {
console.log('Upload from Camera');
var options = {
quality: 75,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 300,
targetHeight: 300,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function (imageData) {
$scope.imgURI = "data:image/jpeg;base64," + imageData;
}, function (err) {
});
}
我的「拍攝照片」按鈕,我得到的的console.log
ReferenceError: Camera is not defined at h.$scope.uploadFromCamera
任何建議如下爲什麼ngCordova似乎只要點擊並沒有被正確加載?
軟件版本 科爾多瓦6.0.0 AngularJS的1.3.x
顯示代碼 –