Ion Cordoba Camera does not work

I use the following Git (see code here) as input for building Phonegap and installed the application on my phone correctly (iOS).

The application opens correctly, but when I try to take a picture (clicking a button), nothing happens. It should display the image captured by the camera.

Can someone explain to me what is not working? The tutorial is on the Ionic website.

Alternative: does anyone have a working .git or code for a telephone conversation?

+4
source share
1 answer

Oke, so I realized everything about setting config.xml correctly!

Ionic Phonegap Build

1. NodeJS c9.io(Cloud Environment) NodeJs.

2. Ionic (: )

npm install -g cordova ionic
ionic start myApp tabs 

2a. cd myApp

2b. , ( )

cordova plugin add org.apache.cordova.camera

3. cd www

4. Bower Unzip ngCordova /lib

bower install ngCordova

5. ngCordova index.html

index.html

<script src="lib/ngCordova/dist/ng-cordova.js"></script> 

<script src="cordova.js"></script>

6. app.js 'ngCordova'

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'ngCordova'])

7.

.controller("ExampleCtrl", function($scope, $cordovaCamera) {

    $scope.takePicture = function() {
        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) {
            // An error occured. Show a message to the user
        });
    }

});

8. .html( tab.example ExampleCtrl app.js)

<ion-view view-title="Example">
  <ion-content>
    <img ng-show="imgURI !== undefined" ng-src="{{imgURI}}">
    <img ng-show="imgURI === undefined" ng-src="http://placehold.it/300x300">
    <button class="button" ng-click="takePicture()">Take Picture</button>
  </ion-content>
</ion-view>

9. config.xml. :

https://github.com/phonegap/phonegap-start/blob/master/www/config.xml

+7

Source: https://habr.com/ru/post/1570489/


All Articles