1
据我所知,下面的代码应该使用不同的索引值每次渲染段落三次。相反,它只是渲染最后一个变形。这里发生了什么?
const app = angular.module('app', [])
app.component('test', {
transclude: true,
controller: function($scope, $element, $transclude) {
//The transclusion should appear 3 times right? Since we're appending 3 times?
for(let index of [10, 11, 12]) {
const x = $transclude(Object.assign($scope.$new(true), {index}))
$element.append(x)
}
},
});
angular.bootstrap (document.querySelector('body'), ['app'])
<body>
<test>
<p>This is {{index}}</p>
</test>
<script src="https://code.angularjs.org/1.5.8/angular.js"></script>
</body>