在我的用户使用navigator.camera.getPicture选择附件后,我正在尝试使用图像名称更新div的HTML。我可以正常更新HTML,但不能在用户选择附件后进行更新。我错过了什么容易的事?
Div我想更新。
<div ng-bind-html="attachmentName"></div>
控制器
.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);
}
}