0
I’m having a doubt in the Angularjs that I’m not able to solve, my index.html
is as follows:
<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 in 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;
}
only by defining the value of $scope.error
or $scope.success
, the value is not displayed (I think it should be because of the div
be out of partial
), it is only displayed when I assign the value in $rootScope
, but the value keeps being displayed until there is some redirection, it is not cleaned when some ajax request is executed (the automatic of angular).
But in short, my question is, is there any way to display the value of $scope
out of partial
? if not, as I do to clear the value of the $rootScope
without having to refresh the page?
the
$scope.error
is a string? because theng-show
has to receive an expression to know if it displays or not.– Rafael
In Boolean comparisons, javascript considers any non-zero value as
true
, as you can see in the following code snippet:var teste = "teste";
 if (teste) { 
 alert(teste); 
 }
– Dennis
I took a look at your code and didn’t see a controller pro index.html, maybe that’s your problem.
– Maicon Funke