Jasmine unit tests: compiling a compiler compiler from ng-repeat

Why line

var scope = $rootScope.$new(); dump($compile('<ul><li ng-repeat="item in [1,3,5,7,9]">{{item}}</li></ul>')(scope)); 

leads to:

 '<ul class="ng-scope"><!-- ngRepeat: item in [1,3,5,7,9] --></ul>' 

I would like to see <li> elements, not comments.

+7
source share
1 answer

you failed to execute the digest method

 var e = $compile('<div><ul><li ng-repeat="item in [1,3,5,7,9]">{{item}}</li></ul></div>')(scope); scope.$digest(); console.log(e.html()); 

This is the result that I am getting now:

 Safari 537.21 (Linux) LOG: ' <ul><!-- ngRepeat: item in [1,3,5,7,9] --> <li ng-repeat="item in [1,3,5,7,9]" class="ng-scope ng-binding">1</li> <li ng-repeat="item in [1,3,5,7,9]" class="ng-scope ng-binding">3</li> <li ng-repeat="item in [1,3,5,7,9]" class="ng-scope ng-binding">5</li> <li ng-repeat="item in [1,3,5,7,9]" class="ng-scope ng-binding">7</li> <li ng-repeat="item in [1,3,5,7,9]" class="ng-scope ng-binding">9</li> </ul>' 
+16
source

All Articles