简体   繁体   中英

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. 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.

<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". How to inject "rec" variable in record_template?

Thanks in advance.

you can use the @input annotation in your directive component

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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