Using $ rootscope AngularJs

Posted on

Question :

I wonder if it’s ok to use $rootscope this way?

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

    

Answer :

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *