Javascript 为什么在测试指令时ngRepeat作为注释呈现?

Javascript 为什么在测试指令时ngRepeat作为注释呈现?,javascript,unit-testing,angularjs,Javascript,Unit Testing,Angularjs,我目前在测试代码时遇到问题。它很好用。 总之,代码使用指令呈现模板。模板内部有一个ngRepeat指令。无论出于何种原因,模板都呈现为 <!-- ngRepeat: current in upcoming.data | filter:query | orderBy :orderProp --> 测试代码 describe( 'directives', function() { var $httpBackend, $compile, $rootScop

我目前在测试代码时遇到问题。它很好用。 总之,代码使用指令呈现模板。模板内部有一个ngRepeat指令。无论出于何种原因,模板都呈现为

<!-- ngRepeat: current in upcoming.data | filter:query | orderBy
:orderProp -->
测试代码

describe(
    'directives',
    function() {
        var $httpBackend, $compile, $rootScope,$document, modalTemplate,mockWebinar;

        beforeEach(module('hublishedEmbed'));
        beforeEach(module('partials/content-embed.html'));
        beforeEach(module('partials/recorded-list.html'));
        beforeEach(module('partials/upcoming-list.html'));
        beforeEach(module('partials/modal-template.html'));
        beforeEach(module('mockWebinar','mockHub','mockUpcomingHub'));

        beforeEach(function() {
            inject(function(_$rootScope_, _$compile_, _$httpBackend_,_$document_) {
                $rootScope = _$rootScope_;
                $compile = _$compile_;
                $document=_$document_;
                $httpBackend = _$httpBackend_;
            });
        });

        /**
         * Compile an HTML element.
         * Required to process directives
         */
        function compileElement(element){
            $compile(element)($rootScope);
            $rootScope.$digest();
        }

        /**
         * Get mock data for Upcoming
         * Populates the HttpBackend mock object
         * uses test/mock/mockUpcomingHub.js
         */
        function getMockUpcomingData() {
            // Need to inject the mock webinar data from the module
            inject(function(mockUpcomingHub) {
                $httpBackend
                        .expectPOST(
                                '/HublishedEmbed/services/webinar/getUpcomingForPublisher?publisherId=1&token=testToken')
                        .respond(mockUpcomingHub);

            })

        }

        //Test upcominghub is formatted properly
        it("upcominghub directive should use the upcoming-list template", function() {
            getMockUpcomingData();
            var element= angular.element('<div><upcominghub publisherid="1"><b>Nada</b></upcominghub></div>');
            compileElement(element);
            console.log(element.html());
            expect($('div.hubCalEvent').length).toBe(6);
        });

        /**
         * TODO figure out how to show that the ngRepeats are formatting correctly.
         * Currently cannot figure out why $digest is rendering the ng-repeats as
         * a comment
         */

    });

如果你张贴一些小提琴或是插曲,那就太好了
describe(
    'directives',
    function() {
        var $httpBackend, $compile, $rootScope,$document, modalTemplate,mockWebinar;

        beforeEach(module('hublishedEmbed'));
        beforeEach(module('partials/content-embed.html'));
        beforeEach(module('partials/recorded-list.html'));
        beforeEach(module('partials/upcoming-list.html'));
        beforeEach(module('partials/modal-template.html'));
        beforeEach(module('mockWebinar','mockHub','mockUpcomingHub'));

        beforeEach(function() {
            inject(function(_$rootScope_, _$compile_, _$httpBackend_,_$document_) {
                $rootScope = _$rootScope_;
                $compile = _$compile_;
                $document=_$document_;
                $httpBackend = _$httpBackend_;
            });
        });

        /**
         * Compile an HTML element.
         * Required to process directives
         */
        function compileElement(element){
            $compile(element)($rootScope);
            $rootScope.$digest();
        }

        /**
         * Get mock data for Upcoming
         * Populates the HttpBackend mock object
         * uses test/mock/mockUpcomingHub.js
         */
        function getMockUpcomingData() {
            // Need to inject the mock webinar data from the module
            inject(function(mockUpcomingHub) {
                $httpBackend
                        .expectPOST(
                                '/HublishedEmbed/services/webinar/getUpcomingForPublisher?publisherId=1&token=testToken')
                        .respond(mockUpcomingHub);

            })

        }

        //Test upcominghub is formatted properly
        it("upcominghub directive should use the upcoming-list template", function() {
            getMockUpcomingData();
            var element= angular.element('<div><upcominghub publisherid="1"><b>Nada</b></upcominghub></div>');
            compileElement(element);
            console.log(element.html());
            expect($('div.hubCalEvent').length).toBe(6);
        });

        /**
         * TODO figure out how to show that the ngRepeats are formatting correctly.
         * Currently cannot figure out why $digest is rendering the ng-repeats as
         * a comment
         */

    });