我是AngularJS的新手。
我在删除图片时遇到页面重新加载的问题。例如,我上传了3张图片。如果我删除图像堆叠顺序,则效果很好。如果我在任何图像之间删除,则会重新加载页面。
<div class="col-md-3 onboardup--image-container" ng-repeat="photo in pet.photos">
<div class="img-div" style="background-image: url({{photo.photo_url}});"></div>
<div class="btn-container">
<button ng-click="removeImage(photo, $event)" class="btn btn-primary" ng-if="newPet == 'true'">
Delete
</button>
</div>
</div>
$scope.removeImage = function(photo, $event){
var target = $event.target;
var container = $(target).parent().parent();
container.remove();
var index = $.inArray(photo, $scope.photoSrcList);
$scope.photoSrcList.splice( index, 1);
$scope.pet.photos.splice( index, 1);
};
感谢您提供的任何帮助。
可能与以下内容重复:AngularJS,单击表单中的按钮会导致页面刷新
尝试添加:type='button'
到您的<button>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句