function armyController($scope, $http) {
var no_errors = true;
function getArmyData () {
$http
.get('/army')
.success(function(data) {
$scope.army = data;
getArmyData();
})
.error(function(data) {
console.log('Error: ' + data);
no_errors = false;
});
}
if (no_errors) {
getArmyData();
}
}
This controller works but it is kind of ugly. How should I keep the $scope updated in a less hacky more efficient way?