Hello StackOverFlow members.
This is my code.
var app = angular.module('app', []);
app.controller("ctrl", ['$scope', '$http', function ($scope, $http) {
var promise = $http.get("url1")
.then(function (response) {
console.log(response);
$scope.files = []
return $http.get('url2', {
params: {
id: response.data[0].Id
}
})
})
.then(function (response2) {
console.log(response2);
$scope.files = response2.data;
return response2.data;
})
}])
my HTML
div ng-app="app" ng-controller="ctrl">
<script type="text/ng-template" id="category">
<a href="{{file.Url}}"><strong>{{file.Name}}</strong></a>
<ul ng-if="(files | filter:{ParentId : file.Id}).length > 0">
<li ng-repeat="file in files | filter: {ParentId : file.Id" ng-include="'category'"></li>
</ul>
</script>
<ul class="btn-highlight plus">
<li ng-repeat="file in files | filter: {ParentId : 0}" ng-include="'category'"></li>
</ul>
</div>
I have a question, ParentId is just a variable, ParentId = response.data.Id, how can I include in my $ scope.files the response and the response2 at the same time and show the response.data.Id in my html code .