0
AngularJS中的ng-repeat似乎不適用於生成器函數。它在控制器中按預期工作,但在HTML表達式中使用時,生成器似乎已被終止。你可以向一個有角度的noob解釋什麼是巫術嗎?使用發生器在AngularJS中迭代使用ng-repeat不能按預期工作
function Main($scope) {
$scope.items = function*() {
//console.log(1);
yield 1;
//console.log(2);
yield 2;
return null;
}();
//console.log($scope.items);
//console.log($scope.items.next().value);
//console.log($scope.items.next().value);
}
<div ng-app ng-controller="Main">
<h2>{{items.next()}}</h2>
<div ng-repeat="item in items">
Hi {{item}}
</div>
</div>
http://jsfiddle.net/4ouae9wm/1/