Hi guys, well i'm new in angular so I'm trying to put my crud in one
controller (i think that is better to see the code and maintainability).
The code is working good, but i have an array in controller that get the
list from my service (resource rest).

the problem is when i go to any page that this controller is used, the
array is called. Seeing others forums the people said to create other
MyControllerList just to call this array from my service, but i want use
one controller

So, exist some way to call this array just when I route to list page?

Ex:

angular.module('frontendApp')
.controller('UserController', function ($scope, UsuarioService) {

    //called to create user in ng-click
    $scope.addUsuario = function(usuario) {
        UsuarioService.save(usuario);
        console.log("Finish.");
    };

        //return the list of users;
        //called every time that the controller is used.
       UsuarioService.query(function(data) {
            console.log(data._embedded.usuario);
            $scope.users = data._embedded.usuario;
        });
});

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to