I've been trying to affect an variable in the parent scope to toggle ng-show from inside a directive. The directive is custom directive containing an ng-repeat directive. The idea, is that once the ng-repeat finishes, I want to hide the containing div as well as the elements inside of it.
Here's a Plunkr demonstrating my situation: http://beta.plnkr.co/edit/C42Z25?p=preview Also here's a comparison in JSFiddle, which uses the same problem, but it's not an ng-repeat and so it works: http://jsfiddle.net/dyzPC/
So there's several problems. Inside my directive, I have to use scope.$parent.showMe = true to change the parent scope's showMe, I can't seem to just use scope.showMe = true to set it. I tried with isolate scopes, no scopes, true scopes, nothing seems to work.
Furthermore, in a jquery callback function I cannot seem to reset the parent scope showMe as scope.$parent.showMe = false. This prevents me from showing the containing div when there's content, and hiding it when there's no content.
On a side note, one final problem is the usage of $last. In the plunkr example, using $last is possible, but in my real code, the ng-repeat collection is being filled up from an HTTP response interceptor. This seems to prevent $last from be used, as all the elements end up as $last = true. Is there a another way to detect when an ng-repeat has finished?