What I'm trying to show the contents of ng-repeat
after calling AJAX (i.e. $http
)
<table ng-controller="TableController as tc">
<tr>
<th>Date</th>
<!-- other headers are here -->
</tr>
<tr ng-repeat="order in tc.orders" >
<td ng-bind="order.id"></td> //It doesn't appear
<td>@{{ order.id }}</td> //It doesn't appear as well. I use Laravel, so I need to put @
</tr>
</table>
Here is the relevant script part
angular.module('adminAngular', ['ui.bootstrap','dialogs.main'])
.controller('TableController', function(dialogs, $http){
var instance = this;
this.orders = [];
$http({
method : "POST",
url : "/admin/getOrders"
}).then(function (response) {
this.orders = response.data;
console.log("Inside; "+this.orders.length);
});
});
From console.log("Inside; "+this.orders.length)
, I can see that the expected data was assigned to this.orders
array. However, as the title of this post suggests, the array is not displayed with ng-repeat="order in tc.orders"
.
I followed this question, but following this did not solve this issue. Now I suspect that the cause lies in the as
statement, which I have to use for this occasion.
As I don't see many information resources about the as
online, I'd appreciate if you'd give any advice.