I'm trying to update the HTML of a div with an image name after my user selects an attachment using navigator.camera.getPicture. I can get the HTML to update normally, but not after the user selects an attachment. What easy thing am I missing?
Div I want to update.
<div ng-bind-html="attachmentName"></div>
Controller
.controller('SubmitTicketCtrl', function($scope, $ionicLoading, $ionicPopup,
SubmitTicketService) {
$scope.submitData = {};
$scope.attachment;
$scope.attachmentName = 'No attachment selected'; // This works.
$scope.addAttachment = function() {
navigator.camera.getPicture(onSuccess, onFail, { // This works fine.
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
targetWidth: 800,
targetHeight: 800
});
function onSuccess(imageURI) {
alert(imageURI.substr(imageURI.lastIndexOf('/') + 1)); // I can see the image name in the popup
$scope.attachmentName = imageURI.substr(imageURI.lastIndexOf('/') + 1); // This doesn't work
$scope.attachment = imageURI;
}
function onFail(message) {
alert('Failed because: ' + message);
}
}