I'm tired of writing code
$scope.getTour = function () { $http({ url: "/tour/tour/" + $routeParams.id, method: "POST" }).success(function (data) { $scope.formData = data; }).error(function (data, status, headers, config) { $scope.status = status; }); }; $scope.onChangePublish = function (newValue, oldValue, tour_id) { $scope.published = newValue ? 1 : 0; $http({ url: "/tour/update-tour", method: "POST", data: { id: tour_id, published: $scope.published } }).success(function (data) { $scope.formData = data; }).error(function (data, status, headers, config) { $scope.status = status; }); }; I read that this is a bad tone, as it is necessary to make a request to the server in a separate service (factory) and continue to use one function. Tell me an example