title: How to trigger export to csv for a table data from a different template in angularjs?
body: <p>In a html body I have 2 templates one for header and other for template. Header template has a <code>save and download</code> button which is supposed to export a ngTable data to a csv file <a href="https://github.com/esvit/ng-table-export">using ngTable Export</a>, which is inside a contents.html template file, but this export only works when I place an anchor tag with click handler to export in the same template. </p>
  
  <p>content.html (template 1)</p>
  
  <pre><code>&lt;a class="btn btn-default export-btn" ng-click='csv.generate($event, "report.csv")' href=''&gt;Export&lt;/a&gt; &lt;!-- this works --&gt;
  &lt;table ng-table="tableParams" show-filter="true" class="table" export-csv="csv"&gt;
          &lt;tr ng-repeat="item in $data" height="10px" class="animate" ng-animate="{enter: 'animate-enter', leave: 'animate-leave'}"&gt;
              &lt;td data-title="'Date'" align="center" filter="{ 'date': 'text' }" sortable="'date'"&gt;{{ item.date | date: 'd MMM yyyy' }}&lt;/td&gt;
              &lt;td data-title="'Label'" align="center" filter="{ 'label': 'text' }" sortable="'label'"&gt;{{item.label}}&lt;/td&gt;         
              &lt;td data-title="'Count'" align="center" filter="{ 'count': 'text' }" sortable="'count'"&gt;{{item.count}}&lt;/td&gt;
          &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>header.html (template 2)</p>
  
  <pre><code>&lt;button class="save-button" ng-click='csv.generate($event, "report.csv")'&gt;&lt;/button&gt; &lt;!-- does not work--&gt;
  </code></pre>
  
  <p>Please help me in exporting table content to csv with a button on a separate template.</p>
  
  <p><strong>Update</strong></p>
  
  <p><a href="http://plnkr.co/edit/2qwzOnw71Ww1E5lGE9AK?p=preview">Unfinished plunker link.. export not working somehow in plunker</a></p>