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.

2 answers

  • answered 2017-06-17 18:05 Amr Alaa

    you can use the @input annotation in your directive component

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

  • answered 2017-06-17 18:05 Arun

        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