I have a http service and with the code i have, i received 5 ids, but i would like to call the 5 ids using an if cycle in my controller.
With the ids, in response2, i get 3 folders and 2 files, but i want to do an if cycle when the object is a folder, i will access the files and the folders inside the folder.
Folders can have folders and files inside and i want to call them using their ids with an if cycle.
Angular Controller
var app = angular.module('app', []);
app.controller("ctrl", function ($scope, $http) {
$scope.accessfolders = [];
$scope.files = [];
var promise = $http.get("link1-getting-the-id - main-folder")
.then(function (response) {
console.log(response);
return $http.get('link2-using-the-first id', {
params: {
id: response.data[0].Id //I got an id with the first id, and I called 3 folders and 2 files//
}
})
})
.then(function (response2) {
console.log(response2);
$scope.accessfolders = function () {
if (response2.data.IsFile = false) //I have a property called IsFile, if IsFile = false, the object is a folder//
return $http.get('link2-using-the-ids-that-i-got-with-response2', {
params: {
id: response2.data[0].Id //I typed data[0] for testing, but it didn't work, my idea is to access every file and folder in response2 with an if cycle using their ids.
}
})
}
$scope.files = response2.data;
return response2.data;
})
})
my HTML
<div ng-app="app" ng-controller="ctrl">
<table class="table">
<tr ng-repeat="file in files" ng-if="file.isFile == accessfolders">
<td>{{file.Name}}</td> // I would like to show every call in my html.//
</tr>
</table>
</div>
Thanks for reading.