Please correct me if I'm wrong: I want to get different types of bills for different tables in my view and this is the way I thought would be the best. Which is probably not.
In my view, I call:
Table 1:
{{billsTypeVariableIncome}}
Table 2:
{{billsTypeVariableBills}}
This is how my controller looks like:
$scope.billsTypeVariableIncome = getBillsByType(1);
$scope.billsTypeVariableBills = getBillsByType(2);
function getBillsByType(bill_type){
$http.get("/api/bills/by/type/"+bill_type).
success(function(data){
return data;
}).
error(function(data){
console.log('Error ' + data);
})
}
Im a rookie(obviously) so probably my approach is wrong. Any help is much appreciated!
getBillsByTypebefore calling it, JavaScript is executed from top to bottom. Also,getBillsByTypedoesn't return anything. You should set the$scopevariables inside the success callback of the$httppromise.