My get_tracking() function returns an object with the summary property.
I tried a few different ways to make this work but I haven't had any luck. To solve this, I would either like to bind the summary property to the pack object or just have it appear in the table.
In this code I am first pulling all packs from the database and storing in $scope.packs. I would then either like to run the get_tracking() function on each one and have the summary attribute applied to each pack.
Is there a way to run a function on each pack once it is returned from the database? When I try to run function in angular I don't have any luck because the pack objects have not yet been returned.
html:
<tbody>
<tr data-ng-repeat="pack in packs"
data-ng-show="((authentication.user) && (authentication.user._id == pack.user._id))">
<td data-ng-bind="pack.tracking_number"></td>
<td data-ng-bind="pack.description"></td>
<td data-ng-bind="pack.company"></td>
<td data-ng-bind=""></td>
<td data-ng-bind="get_tracking(pack).summary"></td>
<td ng-bind=""></td>
</tr>
</tbody>
JS
$scope.get_tracking = function (packet) {
if (packet){
$http.post('/tracking', packet).success(function(response) {
return response.summary;
}).error(function(response) {
});
}
};
Aucun commentaire:
Enregistrer un commentaire