I'm really new to AngularJS, and after reading a few questions and some articles, I got a little confused about the correct way to load data and waited for it to load to display the view.
My controller is as follows
app.controller('ResultsController', ['$scope','$http', '$routeParams', function($scope, $http, $routeParams) {
$scope.poll = {};
$scope.$on('$routeChangeSuccess', function() {
showLoader();
$http.get("rest/visualizacion/" + $routeParams.id)
.success(function(data) {
$scope.poll = data;
hideLoader();
})
.error(function(data) {
});
});
}]);
I saw that there are people who create a service for calling $ http, is this necessary? Why is it better?
source
share