角度附加组件到各个选项卡 [英] angular append component to respective tabs
问题描述
我正在尝试使用角形材料和@viewChild
将组件(动态创建的)附加到各个选项卡,但是只有在单击第二个选项卡中的按钮时,它才会转到第一个选项卡.
I am trying to append component (dynamic created) to respective tabs using angular material and @viewChild
but it is going to first tab only when I click button in the 2nd tab.
这是 Stackblitz-angular-append-组件到相应的标签
Here is Stackblitz - angular-append-component-to-respective-tabs
它没有显示在单独的选项卡中.我有3个标签.所有三个选项卡都包含Add
按钮,当我单击第一个选项卡的按钮时,它将在第一个选项卡中添加该组件,但是当我单击第二个选项卡的Add
按钮时,它将仅在第一个选项卡中添加该组件,应该将其添加到第二个标签.
It's not displaying in individual tab. I have 3 tabs. all 3 tabs contains Add
button, when I click on 1st tab's button, it's adding that component in 1st tab but when I click on 2nd tab's Add
button, it's adding that component in 1st tab only, it should add in 2nd tab.
有人可以帮我弄清楚该怎么做吗?
Can someone please help me to figure-out how to do this?
推荐答案
在此处提供工作示例使用ViewChild,您始终可以访问第一个.使用ViewChildren并使用selectedIndex
With ViewChild you always access the first one. Use ViewChildren and access with the selectedIndex
这篇关于角度附加组件到各个选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!