Javascript 摄像头插件没有';我不能在爱奥尼亚工作
我想使用相机插件和文件上传在爱奥尼亚拍照。但是,当我点击按钮时,它不起作用。我看了看控制台,没有错误 视图:Javascript 摄像头插件没有';我不能在爱奥尼亚工作,javascript,android,angularjs,ionic-framework,Javascript,Android,Angularjs,Ionic Framework,我想使用相机插件和文件上传在爱奥尼亚拍照。但是,当我点击按钮时,它不起作用。我看了看控制台,没有错误 视图: <button class="button button-full button-assertive" ng-click="takePhoto">Take Photo</button> <button class="button button-full button-assertive" ng-click="choosePhoto">Choose Ph
<button class="button button-full button-assertive" ng-click="takePhoto">Take Photo</button>
<button class="button button-full button-assertive" ng-click="choosePhoto">Choose Photo</button>
<img ng-src="{{user.picture}}">
感谢所有的帮助。
我是新手。首先使用以下命令安装摄像头插件
cordova plugin add cordova-plugin-camera
然后,尝试实现以下代码以从相机拍照
HTML文件,
<ion-content>
<button class="button button-full button-assertive" ng-click="takePhoto">Take Photo</button>
<img ng-src="{{ImagePath}}" style="width:250px;height:250x;"/><br/>
<ion-content>
希望这能帮助你 您没有在工厂使用$CORDOVA摄像头,也没有使用所有图像选项,请参阅ngCordova摄像头插件的官方文档
拍照
请使用适当的ng click功能与控制器绑定。使用以下简单控制器查看其是否工作。也不要忘记安装Cordovacamera插件。我没有看到你的代码使用任何科尔多瓦插件
app.controller('MainCtrl', function($scope, $cordovaCamera) {
$scope.takeImage = function() {
var options = {
quality: 80,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 250,
targetHeight: 250,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.srcImage = "data:image/jpeg;base64," + imageData;
}, function(err) {
// error
});
}
});
在index.html中使用以下代码
<ion-content ng-controller="MainCtrl">
<img ng-src="{{srcImage || 'img/dummy.jpg'}}" id="srcImage" width="250 "
height="250" style="display: block; margin: 0 auto;"/><br/>
<button class="button button-full button-positive " ng-click="takeImage() ">Take Image</button><br/>
</ion-content>
拍摄图像
<button class="button button-full button-assertive" ng-click="takePictures">Take Photo</button>
app.controller('MainCtrl', function($scope, $cordovaCamera) {
$scope.takeImage = function() {
var options = {
quality: 80,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 250,
targetHeight: 250,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.srcImage = "data:image/jpeg;base64," + imageData;
}, function(err) {
// error
});
}
});
<ion-content ng-controller="MainCtrl">
<img ng-src="{{srcImage || 'img/dummy.jpg'}}" id="srcImage" width="250 "
height="250" style="display: block; margin: 0 auto;"/><br/>
<button class="button button-full button-positive " ng-click="takeImage() ">Take Image</button><br/>
</ion-content>