1

I'm trying to extract a raw HTML table of data from a table which I currently generate on a web page using AngularJS.

To give a simple example:

Angular code:

  <table>
    <tr ng-repeat="customer in customers">
        <td>{{customer.firstname}}</td>
        <td>{{customer.lastname}}</td>
    </tr>
  </table>

I don't want to code two different solutions and so would like to use AngularJS.

Is it possible to extract the raw html code using AngularJS? i.e. the following :

  <table>
    <tr>
        <td>John</td>
        <td>Smith</td>
    </tr>
    <tr>
        <td>Fred</td>
        <td>Bloggs</td>
    </tr>
    ...etc
  </table>
Loofer
  • 6,841
  • 9
  • 61
  • 102
Jeff Yates
  • 1,053
  • 1
  • 10
  • 14
  • 2
    You should consider it render at server side then. Maybe this will help : http://stackoverflow.com/questions/16232631/angularjs-server-side-rendering – fuyushimoya Jun 17 '15 at 15:49
  • I may go that route, so its a useful pointer. I would prefer to keep it client side if possible though. – Jeff Yates Jun 18 '15 at 08:24

1 Answers1

2

you can use

  var element = angular.element(element)

   element[0] //show give raw dom element

refer jqlite and below link in angularJS , probably will get idea https://docs.angularjs.org/api/ng/function/angular.element

Fiddle: https://jsfiddle.net/shushanthp/Lho8myw2/

Shushanth Pallegar
  • 2,832
  • 1
  • 14
  • 16