2017-08-04 1 views
0

Ich versuche, das Cordova Camera Plugin zu implementieren, um es Benutzern zu ermöglichen, Fotos mit ihrer Kamera zu machen, indem sie meine vorhandene Cordova/AngularJS Mobile App verwenden.Kamera ist nicht definiert

Ich versuche, die Methoden in diesem Artikel zu verwenden (und das funktioniert gut für eine neue frische Anwendung Cordova) http://sourcefreeze.com/cordova-camera-plugin-example-using-ionic-framework/

Ich habe die ngCordova.min.js gruntfile hinzugefügt, die diese Datei an die Anwendung fügt wenn es durch den Schluckprozess geht.

Innerhalb der app.js ich das Modul hinzugefügt haben, wie unten (bitte beachten Sie, ich habe die ganze app.js aufgrund seiner Länge nicht hinzugefügt)

// app.js

var hqApp = angular.module('hqApp', [ 'hqControllers', 'hqFilters', 'hqServices', 'hqDirectives', 
'ngMaterial', 'ngCordova' ]); // ngCordova has been added to the array 

// HTML-Ansicht

<button class="button button-full" ng-click="uploadFromCamera()"> 
    Take Photo 
</button> 

<img ng-show="imgURI !== undefined" ng-src="{{imgURI}}" style="text-align: center"> 

// Steuerung (nicht der gesamte Controller aufgrund Länge)

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) { 

    }); 
} 

Jedes Mal, wenn ich auf die Schaltfläche ‚Take Photo‘ ich folgendes in der console.log

ReferenceError: Camera is not defined at h.$scope.uploadFromCamera 

Irgendwelche Vorschläge, warum die ngCordova scheinen wird nicht richtig geladen werden?

Software-Versionen Cordova 6.0.0 AngularJS 1.3.x

+0

anzeigen Code fixiert verbunden –

Antwort

0

hatte ich ein Build-Skript, das nicht zu ngCordova Verknüpfung wurde - jetzt, wo Sie Cordova haben