Hello,
I'm in a process of creating a small app where upon clicking a button a
popup is opened (via mdDialog service) and two options are presented: Open
Camera and Open Gallery.
The returned url is then attached to the scope.
I've encountered two problems:
1. When I click the Open Gallery option and choose a picture from the
gallery, the picture is not displayed. The one taken by the camera is,
however.
2. When the camera option is chosen and a picture is taken , it is
displayed, but once the camera option is chosen again, I want the new
picture taken to be displayed instead of the old one, but the old one
remains unchanged. As if this only works on the first time.
*Script:*
*$scope.OpenCameraPopup = function () {
$mdDialog.show({ controller:
DialogController, templateUrl:
'CameraPopup.html',
clickOutsideToClose: true
}).then(function (answer) { if
(answer == 'camera') {
CameraService.takePic().then(function (FileUrl) {
$scope.picSrc = FileUrl;
}, function (err) { alert(err); });
}
else if (answer == 'gallery') {
CameraService.openGallery().then(function (FileUrl) {
$scope.picSrc = FileUrl;
}, function (err) { alert(err); });
}
else { alert("Could not open Camera/Gallery");}
}); };Camera Service:*
factory("CameraService", function ($q) {
var CameraPromise = $q.defer();
var GalleryPromise = $q.defer();
var takePic = function () {
navigator.camera.getPicture(function (fileUrl) {
CameraPromise.resolve(fileUrl);
}, function (err) {
CameraPromise.reject(err);
}, {
quality: 100
});
return CameraPromise.promise;
}
var openGallery = function () {
navigator.camera.getPicture(function (fileUrl) {
GalleryPromise.resolve(fileUrl);
}, function (err) {
GalleryPromise.reject(err);
}, {
quality: 100,
sourceType:
Camera.PictureSourceType.PHOTOLIBRARY
});
return GalleryPromise.promise;
}
return {
takePic: takePic,
openGallery: openGallery
}
})
*HTML:*
* <img class="md-avatar" src={{picSrc}}
ng-click="OpenCameraPopup()" />*
What could be the problem here? Any help would be very much appreciated.
Thank you!
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.