Ionic Mixed Development summary call phone camera

Source: Internet
Author: User

Tidy up, to contact Ionic's partners for some reference, less detours.

The phone is invoked only if the project has been successfully created.

First of all, to download two plugins, one is Cordova-plugin-camera, is to call the camera plug-in, there is a Ngcordova, specific commands themselves Baidu, many online.

After downloading Ngcordova, do not forget to add a dependency in app.js, of which the Ngcordova is dependent,

varApp = Angular.module ('Starter', ['Ionic','Ngcordova','starter.controllers','Starter.logincontroller'  ,'Starter.zoufang','Starter.zaixian',  'Starter.tongbao','Starter.wentishouji','Starter.zhanshicontroller','Starter.zerencontroller'])

Define the method of calling the camera, here is not more than nine photos.

Where options are the parameters that are set when the camera is called,

DestinationType is the data format returned after the shot is completed, Base64 encoded here,
SourceType for camera capture or album selection, here for cameras
Savetophotoalbum to Save to a mobile album

It is important to note that the controller does not forget to add $cordovaCamera

One of the methods of uploading images is ignored, here is the method given in the background,

get ImageData, you can do some processing, whether it is upload, or display can be manipulated.
1$scope. Getcamera =function () {2       if($scope .data.y_image.length<9){3         varOptions = {4Quality: -,5 DestinationType:Camera.DestinationType.DATA_URL,6 SourceType:Camera.PictureSourceType.CAMERA,7           //Allowedit:true,8 EncodingType:Camera.EncodingType.JPEG,9Targetwidth:480,TenTargetheight:720, One Popoveroptions:camerapopoveroptions, ASavetophotoalbum:false -         }; - $cordovaCamera. Getpicture (Options). Then (function (imageData) { the           varImageData =ImageData; -$scope. Data.isimage =true; - $ionicLoading. Show ({ -Template'the picture crosses ...' +           }); - client. UpdateImage (ImageData, function (result) { + $ionicLoading. Hide (); A$scope. Data.y_image.push ({'src':"Data:image/jpeg;base64,"+ ImageData,'Val':'/yuonhtt_fileupload/img/'+result}); at $scope. $digest (); - }, function (name, err) { - alert (err); -           }); - }, function (err) { - Console.log (err); in         }); -}Else{ to         varConfirmpopup =$ionicPopup. Alert ({ +Title'Reminders', -Template'upload more than 9 photos!', theOktext:'Confirm', *Oktype:'button-assertive' $         });Panax Notoginseng Confirmpopup.then (function (res) { -         }); the       } +  A};

Ionic Mixed Development summary call phone camera

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.