I'm writing an angular app where I need to bind values to some child scope. In the controller, I have:
var addToStack = function(fallingItemOrder, scope) {
scope.model.stageChimneys[fallingItemOrder].Stack += 1;
return (scope.model.stageChimneys[fallingItemOrder].Stack === 3);
};
Where scope is referenced to $scope with $id=2 (I guess it's 2 because it lives under an ng-view directive.)
The main view has this code:
<ul class="chimneysUL">
<li ng-repeat="chimney in model.stageChimneys" ng-include="model.chimneyUrl"></li>
</ul>
And the ng-include fetches this sub-view, which is rendered 5 times with different data:
<div class="chimney" id="{{chimney.LetterCode}}" data-order="{{$parent.$index}}">
<div class="pipeHead"></div>
<div class="pipeBody">
<table class="ulInsertedLetters">
<tr ng-repeat="i in model.getNumber(model.stackSize) track by $index" ng-class="3 - $index <= chimney.Stack ? 'showInserted' : 'hideInserted'">
<td>
<img class="insertedLetterImg" data-ng-src="{{'../../Images/Cards/rectangle.jpg'}}" />
</td>
</tr>
</table>
</div>
<div class="picContainer">
<img class="card" data-ng-src="{{chimney.PicName}}" />
</div>
</div>
All bindings seem to be correct (e.g. chimney.LetterCode etc..)
but when addToStack executes, the {{chimney.Stack}} remains unchanged.
As I understand scopes, if the parent scope with $id = 2 has it's model properties change, then those changes should permeate down and reflect instantaneously in the html view.
And indeed in debugging, I can see that diving into $$childTail --> $$prevSibling, the chimney object has it's Stack property incremented.
So what's the missing part I've overlooked?
addtoStackis even being usedshowInsertedorhideInserteddepending on the calculation in ng-class.