Angularjs $element.append()在转包时不追加

Angularjs $element.append()在转包时不追加,angularjs,directive,angularjs-ng-transclude,Angularjs,Directive,Angularjs Ng Transclude,据我所知,下面的代码应该以不同的索引值呈现该段落三次。相反,它只是呈现最后的转换。这是怎么回事 const-app=angular.module('app',[]) 应用组件(“测试”{ 是的, 控制器:函数($scope、$element、$transclude){ //转义应该出现3次,对吗?既然我们加了3次? for(let索引为[10,11,12]){ const x=$transclude(Object.assign($scope.new(true),{index})) $eleme

据我所知,下面的代码应该以不同的索引值呈现该段落三次。相反,它只是呈现最后的转换。这是怎么回事

const-app=angular.module('app',[])
应用组件(“测试”{
是的,
控制器:函数($scope、$element、$transclude){
//转义应该出现3次,对吗?既然我们加了3次?
for(let索引为[10,11,12]){
const x=$transclude(Object.assign($scope.new(true),{index}))
$element.append(x)
}
},
});
angular.bootstrap(document.querySelector('body'),['app'])

这是{index}


$transcludeFn接受第二个参数,该参数接收应用了新作用域的元素克隆。您希望在此函数中使用克隆将其放入dom中。您可以在此处或此处了解更多信息:

const-app=angular.module('app',[])
应用组件(“测试”{
是的,
控制器:函数($scope、$element、$transclude){
//转义应该出现3次,对吗?既然我们加了3次?
for(let索引为[10,11,12]){
$transclude(
assign($scope.$new(true),{index}),
x=>$element.append(x)
)
}
},
});
angular.bootstrap(document.querySelector('body'),['app'])

这是{index}