Most attributes in Angular are either evaluated or interpolated. Evaluation is like a restricted form of eval()
, interpolation is when the double curly braces get filled in. It looks like you're expecting the ng-show
to be interpolated then evaluated, but none of the built-in directives do this. They do one or the other but not both. For ng-show
specifically it just does evaluation, so your curly braces pass through literally. This would be an invalid expression.
My suggestion is this: Since ng-repeat
creates a new scope for each repeated item, you can just do this:
<div class="row" ng-repeat="item in items" ng-cloak>
<div ng-show="!hide" class="ng-hide">
<button ng-click="hide = true">Remove</button>
</div>
Of course, why keep a bunch of hidden items around. Why not have ng-click="remove(item)"
and a remove function that removes from items? Then the ng-repeat
updates naturally.
$scope.remove = function(item) {
var index = this.items.indexOf(item);
if (index != -1) {
this.items.splice(index);
}
};
Or something like that.