The controller should only be used to interact with the user interface components of the component in question, ie, it is the API that is declared for the functionalities, click a button, order a list, open a dialog, etc.
For the case that you describe, you should use the "service", who is in charge of storing the data model and declaring the operations, consumption of services, business logic. The service to be singleton will be executed once, thus maintaining the state of the data, as well as the execution of operations at the moment of loading the application.
As an example I declare a service:
(function(){
//Las dependencias incluidas en la declaracion del servicio son usadas
function myService(inyecto, multiples, dependencias, notificacion){
//Declaro mis funciones, sin preocuparme por la estructura del servicio. De esta manera tenemos un codigo mejor estructurado
function crear(){
//Mis operaciones
//Como resultado de algunas operaciones puedo invocar otros servicios. De esta forma dividimos responsabilidades
notificacion.notificacionSatisfactoria('Usuario Creado Correctamente')
}
function editar(){
//Mis operaciones
}
function consultar(){
//Mis operaciones
//Como resultado de las operaciones actualizo el modelo de datos, el cual puede estar en el mismo servicio, o en otro.
service.usuario = resultadoDeConsulta;
}
function eliminar(){
//Mis operaciones
}
//Empaquetamos nuestras operaciones y variables, y las declaramos como publicas.
var service = {}
service.usuario;
service.crear = crear;
service.crear = editar;
service.crear = consultar;
service.crear = eliminar;
return service;
}
//Declaro mi servicio al final del archivo, esto me ayuda a concentrarme en las operaciones.
angular.module('myApp')
.service('myService', myService);
//Inyecto las dependencias necesarias para el funcionamiento de mi servicio
myService.$inject = ['inyecto','multiples','dependencias','notificacion'];
})();
In my controller I limit myself to using the services, being able to reuse both the controller and the services, without the problem of duplication of operations