Reputation: 11493
I have the following directive:
<span ng-show="{{ save_state == 'saved' }}"> Saved </span>
<span ng-show="{{ save_state == 'saving' }}"> Saving </span>
<span ng-show="{{ save_state == 'error' }}"> Error </span>
These callbacks are called at various time:
var saving = function() {
$scope.save_state = "saving";
$scope.$apply();
};
var saved = function() {
$scope.save_state = "saved";
$scope.$apply();
};
var error = function(err) {
alert(err);
$scope.save_state = "error";
$scope.$apply();
};
and I also have this statement for debugging
<span> {{ save_state == 'saving' }} </span>
For some reason, even what the span tag above shows true
, the "Saving" span tag does not show. Same for "error". Why?
Upvotes: 0
Views: 81
Reputation: 67296
It is because you are interpolating {{ }}
the contents of the ng-show
Directive:
ng-show="{{ save_state == 'saved' }}"
ng-show
requires that you provide a valid Angular Expression.:
ng-show="save_state == 'saved'"
Upvotes: 1