简体   繁体   English

如何在角度的ng-include内容中注入ng-repeat循环变量

[英]How to inject ng-repeat loop variable in ng-include content in angular

I want to build two table with same record structure. 我想建立两个具有相同记录结构的表。 One table is Main, other table is an Archiv. 一个表是Main,另一个表是Archiv。 The record is a bootstrap divs with col-sm-x structure with {{rec.Name}}, {{rec.Age}} etc. From the record content I made a tablerecord.html template and i want to use in two different ng-repeat to build tables. 记录是具有col-sm-x结构的引导div,其中包含{{rec.Name}},{{rec.Age}}等。从记录内容中,我制作了一个tablerecord.html模板,我想在两种不同的情况下使用ng-repeat建立表格。

<div> ng-repeat="rec in MainTable"><record_template/></div> 
and
<div> ng-repeat="rec in Archiv""><record_template/></div>

To load the record template I use angular directive "recordTemplate". 为了加载记录模板,我使用了角度指令“ recordTemplate”。 How to inject "rec" variable in record_template? 如何在record_template中注入“ rec”变量?

Thanks in advance. 提前致谢。

you can use the @input annotation in your directive component 您可以在指令组件中使用@input批注

https://angular.io/guide/attribute-directives#binding-to-an-input-property https://angular.io/guide/attribute-directives#binding-to-an-input-property

    As i don't know how you written your directive. you can check the below link.

    http://jsbin.com/gopula/1/edit?html,js,output

and try this 

<div> ng-repeat="rec in MainTable" record_template ="rec"/></div> 
and
<div> ng-repeat="rec in Archiv" record_template="rec"/></div>

    Hope this will help you 

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

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