ng-repeat内部指令模板在测试期间不会更新

时间:2014-02-19 10:13:15

标签: angularjs unit-testing jasmine directive ng-repeat

我有一个角度指令的单元测试。该指令在其模板中有一个ng-repeat,它绑定到指令控制器内的一个数组。当调用控制器中的方法时,该数组会发生更改(此方法实际上由子指令调用,如addMe())。 这在'现实生活'中运行良好,但不在Jasmine单元测试中。我可以在调试器中看到,所有内容都被调用,并且数组具有正确的内容,但不知何故ng-repeat将不会更新。在更改数组后,我甚至尝试在控制器内调用$scope.$digest(),但这也不起作用。 有帮助吗? 丹尼尔

模板的相关部分是:

    <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>

1 个答案:

答案 0 :(得分:0)

问题是由ng-animate版本导致的某些不兼容造成的。更新所有内容(目前为1.2.13)解决了这个问题。

相关问题