博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
angularJS拍照
阅读量:7096 次
发布时间:2019-06-28

本文共 2183 字,大约阅读时间需要 7 分钟。

hot3.png

第一步:先上工程目录结构-------------------------------

114313_QipX_2252639.png

说明:开发测试的时候需要在真机上调试拍照功能 不懂的可以加JS前端群:JS前端(HTML5) 458633781

第二步:上主页面HTML-------------------------------index.html

心魅体
This is my take photos list page
 
 
 
 点击“+”完成拍照,本次上传照片最多3张。
OK,SUBMIT

第三步:上app.js-------------------------------takePhoto\www\js\app.js

// Ionic Starter App// angular.module is a global place for creating, registering and retrieving Angular modules// 'starter' is the name of this angular module example (also set in a  attribute in index.html)// the 2nd parameter is an array of 'requires'var exampleApp = angular.module('starter', ['ionic','ngCordova']).run(function($ionicPlatform) {  $ionicPlatform.ready(function() {    if(window.cordova && window.cordova.plugins.Keyboard) {      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard      // for form inputs)      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);      // Don't remove this line unless you know what you are doing. It stops the viewport      // from snapping when text inputs are focused. Ionic handles this internally for      // a much nicer keyboard experience.      cordova.plugins.Keyboard.disableScroll(true);    }    if(window.StatusBar) {      StatusBar.styleDefault();    }  });});exampleApp.controller("ExampleController", 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        });    } });

源码链接:

转载于:https://my.oschina.net/u/2252639/blog/632057

你可能感兴趣的文章
洛谷 P2404 自然数的拆分问题
查看>>
7998元/年:百度推出百科微站服务
查看>>
智能设备如何防丢减损?
查看>>
linux sysrq
查看>>
Incorrect NSStringEncoding value 0x0000 detected.
查看>>
(转)as3数组的深复制和浅复制
查看>>
Choose a destination with a supported architecture in order to run on this device.
查看>>
FreeLing 3.0 - Demonstration
查看>>
HTML5/CSS3系列教程:HTML5 区域(Sectioning)的重要性
查看>>
Spring Batch学习笔记
查看>>
asp.net mvc 如何在执行完某任务后返回原来页面
查看>>
Oracle: listener.ora 、sqlnet.ora 、tnsnames.ora的配置及例子
查看>>
ASP.NET 中 GridView(网格视图)的使用前台绑定
查看>>
Windows的本地时间(LocalTime)、系统时间(SystemTime)、格林威治时间(UTC-Time)、文件时间(FileTime)之间的转换...
查看>>
[转]XBRL应用软件分类
查看>>
C++ 文件的复制、删除、重命名
查看>>
Oracle Patch Set Update and Critical Patch Update April 2011 Released
查看>>
hdu 2189
查看>>
std::map, std::multimap, std::tr1::unordered_map 区别 - 笔记本 - 博客频道 - CSDN.NET
查看>>
/usr/bin/ld: cannot find -lxxx问题总结
查看>>