I am using the factory method to get data from a rest service. My problem is that I would like to display the loading overlay while my get function is executing and hide it when completed. How would I do that in the scenario? Is it something I would do in the factory and not in the controller? I am pretty new to ionic and would appreciate the help. Thanks !!
.factory(‘OpinionFactory’, [’$http’, function($http) {
var dataFactory = {};
dataFactory.getopinions = function () {
return $http.get(myUrl);
};
return dataFactory;
}])
.controller(‘OpinionsCtrl’, [’$scope’, ‘OpinionFactory’, function ($scope, opinionFactory) {
getOpinions();
function getOpinions() {
opinionFactory.getopinions()
.success(function (data) {
$scope.opinions = data;
})
.error(function (error) {
$scope.status = 'Unable to load customer data: ' + error.message;
});
}
}])