I have an http service and with the code I have received 5 ids. I would like to call them using a scope using a cycle if
, the json format has as property isFile
that if it is false it is a folder and if it is true it is a file. My idea is to make a if
that if it is false, make a repeating cycle that calls each id in an automated way.
A folder can have folders and files inside.
No more to say here is my code.
Controller
var app = angular.module('app', []);
app.controller("ctrl", function ($scope, $http) {
$scope.accessfolders = [];
$scope.files = [];
var promise = $http.get("(Primer-Link)primera-llamada-obtuve-un-id")
.then(function (response) {
console.log(response);
return $http.get('(Segundo-Link)Use-el-id-de-la-primera-llamada-para-acceder-a-este-link', {
params: {
id: response.data[0].Id //Obtuve el id de la primera llamada, Y llame a 3 carpetas y 2 archivos (quiero acceder a esas 3 carpetas usando un if)//
}
})
})
.then(function (response2) {
console.log(response2);
$scope.accessfolders = function () {
if (response2.data.IsFile = false) //Tengo una propiedad llamada IsFile, si IsFile = falso, el objecto es una carpeta//
return $http.get('(Segundo-Link)Quiero-llamar-solo-las-carpetas-dentro-de-response2.data', { //fijaros que el primer link es para llamar el id de la carpeta principal y el segundo link para llamar a la carpeta que quiera usando su id//
params: {
id: response2.data[0].Id //No quiero usar [0] o [1], solo quisiera llamar cada que id obtuve con mi response2 de manera automatizada con un ciclo.//
}
})
}
$scope.files = response2.data;
return response2.data;
})
})
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>
</tr>
</table>
</div>