为什么这条线
var scope = $rootScope.$new(); dump($compile('<ul><li ng-repeat="item in [1,3,5,7,9]">{{item}}</li></ul>')(scope));
结果是:
'<ul class="ng-scope"><!-- ngRepeat: item in [1,9] --></ul>'
我想看看< li>项目而不是评论.
你错过了
原文链接:https://www.f2er.com/angularjs/141483.htmldigest
方法,一路走来
var e = $compile('<div><ul><li ng-repeat="item in [1,9]">{{item}}</li></ul></div>')(scope); scope.$digest(); console.log(e.html());
这是我现在得到的输出:
Safari 537.21 (Linux) LOG: ' <ul><!-- ngRepeat: item in [1,9] --> <li ng-repeat="item in [1,9]" class="ng-scope ng-binding">1</li> <li ng-repeat="item in [1,9]" class="ng-scope ng-binding">3</li> <li ng-repeat="item in [1,9]" class="ng-scope ng-binding">5</li> <li ng-repeat="item in [1,9]" class="ng-scope ng-binding">7</li> <li ng-repeat="item in [1,9]" class="ng-scope ng-binding">9</li> </ul>'