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