Angular 将ngFor从一个组件添加到表格

Angular 将ngFor从一个组件添加到表格,angular,Angular,我正在尝试生成一个表,其中有另一个组件插件。让我举例说明一下: action.component.html <ul *ngFor="let action of actions" class="dropdown-menu dropdown-menu-right"> <li><a href="" data-toggle="modal" [attr.data-target]=[action.target]>{{action.text}}</a

我正在尝试生成一个表,其中有另一个组件插件。让我举例说明一下:

action.component.html

  <ul *ngFor="let action of actions" class="dropdown-menu dropdown-menu-right">
       <li><a href="" data-toggle="modal" [attr.data-target]=[action.target]>{{action.text}}</a></li>
  </ul>

  • 上面的html在标签中提供

    <app-actions></app-actions>
    
    
    
    现在我有了另一个组件,我正在使用上面的组件:

          <tr>
            <td>Sample text</td>
            <td>Sample text</td>
            <td>Employee</td>
            <td>
              <app-actions></app-actions>
            </td>
          </tr>
    
    
    示例文本
    示例文本
    受雇者
    

    但问题是应用程序内操作我只能看到操作对象的最后一个
    li
    元素。

    我认为你的*ngFor是错误的。你能试试这个吗:

    <ul  class="dropdown-menu dropdown-menu-right">
         <li *ngFor="let action of actions">
           <a href="" data-toggle="modal" [attr.data-target]=[action.target]>
              {{action.text}}
           </a>
        </li>
    </ul>
    

    Oops。我真糟糕。谢谢