Guest User

Untitled

a guest
Jan 21st, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <table>
  2. <tr>
  3. <th>Firstname</th>
  4. <th>Lastname</th>
  5. <th>Age</th>
  6. </tr>
  7. <tr>
  8. <td>Jill</td>
  9. <td>Smith</td>
  10. <td>50</td>
  11. </tr>
  12. <tr>
  13. <td>Eve</td>
  14. <td>Jackson</td>
  15. <td>94</td>
  16. </tr>
  17. </table>
  18.  
  19. <table style="width:100%">
  20. <tr>
  21. <th>Company</th>
  22. <th>Address</th>
  23. <th>City</th>
  24. </tr>
  25. <tr>
  26. <td>Jill</td>
  27. <td>Smith</td>
  28. <td>50</td>
  29. </tr>
  30. <tr>
  31. <td>Eve</td>
  32. <td>Jackson</td>
  33. <td>94</td>
  34. </tr>
  35. </table>
  36.  
  37. var tableDirective = function(){
  38. return {
  39. restrict: 'EA', //E = element, A = attribute, C = class, M = comment
  40. scope: {
  41. data: '='
  42. },
  43. templateUrl: 'table-directive.html',
  44. }
  45. };
  46.  
  47. angular.module('myModule').directive('tableDirective', tableDirective);
  48.  
  49. <table style="width:100%">
  50. <tr>
  51. <th ng-repeat="item in data.headList">{{ item.name }}</th>
  52. </tr>
  53. <tr ng-repeat="item in data.rowList">
  54. <td>{{ item.name }}</td>
  55. <td>{{ item.surname }}</td>
  56. <td>{{ item.propertyName }}</td>
  57. </tr>
  58. </table>
  59.  
  60. <table-directive data="data"></table-directive>
  61.  
  62. ...
  63. $scope.data = {
  64. headList: [{ name: 'Company' }, { name: 'Address' }, { name: 'City' }],
  65. rowList: // here will be your data
  66. }
  67. ...
Add Comment
Please, Sign In to add comment