1

我写了一个指令。在模板中,我在 ng-repeat 中使用了 ng-include:

 <div ng-repeat="page in wStepPages" id="step{{$index}}"  data-ng-show="getCurrentStep() == $index" ng-include="page.page" class="slide-frame">
</div>

例如,如果我的 page.page = step1.html:

<div>
  <input id="name" ng-model="isolate.name">
</div>

在我的测试规范中:

describe("test_wizard",function () {
var scope,doc,elem,compiled,html;


beforeEach(module('App.wizard','app/partials/step1.html','app/partials/step2.html','app/partials/step3.html','app/partials/step4.html'));
beforeEach(function(){
    html = '<ov-wizard title="OV_WIZARD" step-pages="stepPages" confirm-bt="confirmbt" data="wizardData"></ov-wizard>';
    inject(function($compile, $rootScope){
        scope = $rootScope.$new();

        elem = angular.element(html);
        compiled = $compile(elem);
        compiled(scope);
        scope.$digest();
    })
});

it("do some thing",function(){

expect(elem.find("#name").length).toEqual(1);
});

})

但它返回的是 0 项。任何帮助我!

4

1 回答 1

0

文档

find() - 仅限于按标签名称查找

于 2013-08-14T10:30:06.920 回答