html - How to remove images using angularjs -
i newbie angularjs. succeeded in making fileuploader work , displaying files uploaded. want remove files not want.
here how upload , display works.
html file
<div class="container-fluid"> <error-display error-display-api="errordisplayapi"></error-display> <div ng-controller="complianceitemdocumentcontroller"> <div class="form-inline"> <span class="btn btn-default"> add photo <input ng-model="file" onchange="angular.element(this).scope().file_changed(this)" type="file" accept="image/*"> </span> <button ng-click="removefile()">delete photo</button> </div> <div ng-repeat="images in document"> <label name ="desscription" ng-bind ="images.description"></label><br> </div> </div> </div> javascript file
app.controller('complianceitemdocumentcontroller', ['$scope', '$http', function ($scope, $http) { var url = "http://localhost:/...."; $http.get(url) .success(function (data, status, headers, config) { $scope.document = data; }) .error(function (data, status, headers, config) { $scope.document = undefined; }); $scope.removefile = function() { alert("delete"); }; $scope.file_changed = function(element) { $scope.$apply(function (scope) { var fd = new formdata(); fd.append('file', element.files[0]); var urlpost = "http/....."; var req = { method: 'post', url: urlpost, headers: { 'content- type': undefined }, data: fd} $http(req) .success(function (data, status, headers, config) { alert("uploaded"); }) .error(function (data, status, headers, config) { alert("fail"); }); }); } }]); i should able select images in list , based on selection of file should able call related api remove document using document id. unable figure out how select file , upon selected document id. call method through httppost , deleting file in database. should able display images available thumbnails. plain list of names of files.
thank time , suggestions.
Comments
Post a Comment