Greetings! Here is the JSON data for "names" :
[
{
"file": "file1.zip",
"date": "12-03-2016",
},
{
"file": "file2.zip",
"date": "24-06-2016",
},
{
"file": "file3.zip",
"date": "02-12-2016",
}]
Here is my JavaScript file:
var app = angular.module('app', []);
app.service('service', function($http, $q){
var deferred = $q.defer();
$http.get('newapi.json').then(function(data){
deferred.resolve(data);
});
this.getNames = function(){
return deferred.promise;
}
});
app.controller('FirstCtrl', function($scope, service){
var promise = service.getNames();
promise.then(function(data){
$scope.names = data.data;
$scope.namesplit = $scope.names;
$scope.namesplit.map(function(item) {
item.time = new Date(item.date * 1000);
});
console.log($scope.namesplit);
});
});
And here is the corresponding HTML code:
<tr ng-repeat="name in names">
<td>{{name.file}}</td>
<td>{{name.date}}</td>
<td><button>POST</button></td>
</tr>
My goal is to have a functionality where upon clicking the button, the "file" gets posted to the server using $http.post. I am looking for guidance on how to achieve this.