Use of $rootscope Angularjs

Asked

Viewed 693 times

3

I wonder if it is correct to use the $rootscope in this way?

$scope.buscaChamados = function() {
                        modelSac.buscaChamados()
                          .success(function(data, res) {
                            $rootScope.chamadosSistema = data;
                          });
                       }

1 answer

4

I believe you’re referring to good practice. If this is the case, I imagine that what you want to do (share data with other scopes) can be better implemented via service (or, alternatively, a factory).

In several implementations $rootScope is reserved for use as a pipeline for Broadcasts global.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.