https://angular.io/api/core/ViewContainerRef
如果我想用角度的
ViewContainerRef
到
move()
一个特定的孩子,我是否有更多的能力来选择它而不仅仅是使用
get(index)
? 我看到它有一个
indexOf(ViewRef)
方法,但我不知道如何得到
ViewRef
角度上没有从
视图容器ref
首先。
例如,如果我创建一个如下所示的ViewContainerRef,我如何才能得到
视图参考
的
#button
元素以便我可以移动它,而不必确定其当前索引?有没有办法用这个按钮
ViewChild
在这种情况下?
@ViewChild('list', {read: ViewContainerRef}) list: ViewContainerRef;
@ViewChild('button') button;
<div #list>
...
<button #button>Toggle</button>
...
</div>