I have a ng-repeat directive to show 6 pictures. I do an AJAX call to get the photos from the server to the app. All the data is stored in a scope var called vendor data. Then, in HTML code I do an ng-repeat to show the pictures. There is a button below each picture to take another from the gallery and change it. Here is the code:
HTML code
<div ng-repeat="photo in vendordata.galerias" class="elemento">
<div style="z-index: 10;">
<img class="thumb" ng-src="{{photo.url}}" />
</div>
<div class="" style="text-align: center;">
<button class="" href="#" ng-click="changePic($index)">Change picture</button>
</div>
</div>
</div>
Controller Code:
$scope.changePic = function(identifier){
$scope.elementSek = identifier;
$scope.getPhoto(pictureSource.PHOTOLIBRARY);
};
$scope.getPhoto = function (source) {
// Retrieve image file location from specified source
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source });
};
function onPhotoURISuccess(imageURI) {
// Get image handle
$scope.vendordata.galerias[$scope.elementoSek].url = imageURI;
}
// Called if something bad happens.
//
function onFail(message) {
console.log('Failed because: ' + message);
}
The var has the correct value, before and after the change. But the img don't updates the selected picture. How can I update it?
photo.url?$scope.vendordata.galerias[$scope.elementoSek].url = imageURI;into a$scope.$apply?http://domain.com/galleries/picture.jpg, after the change it returnsfile://path_to_new_file.jpg