Question

I have a unit test for an angular directive. This directive has a ng-repeat inside its template which is bound to an array inside the directive's controller. The array changes when a method in the controller is called (this method actually gets called by a sub-directive, something like addMe()). This works fine in 'real-life', but does not inside a Jasmine unit test. I can see in the debugger, that everything is called and the array has the correct contents, but somehow the ng-repeat won't update. I even tried to call $scope.$digest() inside the controller after a change to the array, but that doesn't work either. Any help? Daniel

Relevant part of the template is:

    <div class="step-wizard-header">
        <div class="step" 
            ng-repeat="title in titles" 
            ng-click="selectPage($index, 0)" 
            ng-class="{ active: currentIndex == $index, done: currentIndex > $index }">
            <span class="number">
                {{$index + 1}}
            </span>
            <span class="title">
                {{title.text}}
            </span>
            <div class="substep-holder" 
                ng-show="currentIndex == $index">
                <div class="substep" 
                    ng-repeat="sub in title.subs" 
                    ng-click="selectPage($parent.$index, $index); $event.stopPropagation()" 
                    ng-class="{ active: currentSubIndex == $index, done: currentSubIndex > $index      }">
                    {{sub.text}}
                </div>
            </div>
            <div class="right-arrow" 
                ng-style="{ 'z-index': (titles.length - $index) }">
            </div>
        </div>
    </div>
Was it helpful?

Solution

The problem was caused by some incompatibility due to the version of ng-animate. Updating everything (to 1.2.13 at the moment) solved the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top