AngularJS value $ scope out of view

0

I have a question in the angularJs that I can not solve, my index.html is the following:

<div ng-show="error" class="alert alert-danger">{{error}}</div>
<div ng-show="success" class="alert alert-success">{{success}}</div>

<div class="content">
   <div ng-view></div>
</div>

To assign value to these views I would normally do the following:

if (response.data.success) {
   $scope.success = response.data.success;
} else if (response.data.error) {
   $scope.error = response.data.error;
}

Just by setting the value of $scope.error or $scope.success , the value is not displayed (I think it should be because div is outside partial ), it only appears when I assign the value in $rootScope , but the value continues to be displayed until there is some redirection, it is not cleared when an ajax request is executed (the angle automatic).

But briefly, my question is, is there any way to display the value of $scope out of partial ? if not, how do I clear the value of $rootScope without having to refresh the page?

    
asked by anonymous 19.06.2016 / 00:22

1 answer

1

Are you using ngRoute? could you please send your complete sample code?

Maybe it will help link

EDITED

Maybe using Factory help you friend, follow an example: link

Hugs

    
20.06.2016 / 18:33