Photography is often used, so remember to take the photo as a replacement...
1.
ionic start camera blank
cd cameraionic platform add ios
2. Add a plug-in, which is familiar ....
1 Cordova plugin add org. Apache. Cordova. Camera
3.
You can refer to ngcordova. Min. js or ngcordova. js in this example.
Then add it to the WWW/lib/ionic/JS file (do not submit ....)
4.reference ngcordova. Min. js in index.html must be earlier than Cordova. js
1
5. In app. JS, Xiaoming references ngcordova
For example
angular.module(‘starter‘, [‘ionic‘,‘ngCordova‘])
6. Add the Controller in APP. js.
For example
1 .controller("cameraController", function($scope, $cordovaCamera) { 2 3 $scope.takePicture = function() { 4 var options = { 5 quality : 75, 6 destinationType : Camera.DestinationType.DATA_URL, 7 sourceType : Camera.PictureSourceType.CAMERA, 8 allowEdit : true, 9 encodingType: Camera.EncodingType.JPEG,10 targetWidth: 300,11 targetHeight: 300,12 popoverOptions: CameraPopoverOptions,13 saveToPhotoAlbum: false14 };15 16 $cordovaCamera.getPicture(options).then(function(imageData) {17 $scope.imgURI = "data:image/jpeg;base64," + imageData;18 }, function(err) {19 // An error occured. Show a message to the user20 });21 }22 23 });
7. Use the extension function in index.html
1 <body ng-app="starter"> 2 3 <ion-pane> 4 <ion-header-bar class="bar-stable"> 5
Ionic ngcordova camera