简体   繁体   English

角度分量DOM添加属性键

[英]angular component DOM add attribute key

I'am looping on DOM element of angular component with ngfor like that 我正在用ngfor循环角度组件的DOM元素

  <td>  
     <button class="dropdown-item" idgroup={{compte_ingroup}} href="#">
       action
     </button>

 </td> 

my question is about to know how to add reference to element create in loop. 我的问题是要知道如何在循环中添加对元素创建的引用。 this issue happen to me ==> Can't bind to 'idgroup' since it isn't a known property of 'button' 这个问题发生在我身上==>无法绑定到“ idgroup”,因为它不是“ button”的已知属性

please what I'am doing wrong? 请我做错了吗?

If what you have is a component which template is 如果您拥有的是组件,则哪个模板是

<td>
...
</td>

you should provide a property to it called idgroup, and when you invoke that component should be something like this: 您应该为其提供一个名为idgroup的属性,并且在调用该组件时应如下所示:

<app-mycomponent *ngFor="let myelement of elementsList" [idgroup]="myelement.idgroup"></app-movie>

and in the component definition: 并在组件定义中:

@Component({
    ...
})
export class MyComponent {
  @Input() idgroup: any;

  ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM