2014-02-06 69 views

回答

0

如果你让他们出现在正确的顺序可以稍微调整你身体的值:

$scope.body = [ 
       ['abc','def','ghi','jkl'], 
       ['123','456','789','222'] 
       ]; 

然后,你可以在一个做到这一点模板很容易。以下是隔离范围示例:

demo.directive("customTable",function(){ 
    return ({ 
      restrict : "A", 
      scope: { 
       header: '=', 
       body: '=' 
      }, 
      template: '<table class="box"><tr><th ng-repeat="head in header">{{head.column}}</th></tr><tr ng-repeat="row in body"><td ng-repeat="cell in row">{{ cell }}</td></tr></table>' 
    }); 
    function link($scope, element, attributes){  
     /* how to make the elements in $scope.body coincide with those in $scope.header*/ 
    } 
}); 

而这里是一个forked plunker

+0

感谢您回复Davin ..元素不会总是按照正确的顺序排列,我们希望避免使用表标签..任何线索? – runtimeZero

+0

你想重新发明一个网格,还是可以使用ng-grid? ng-grid不使用表格标签,可以做你想要的一切以及更多。 –

+0

不想重新发明电网..但需要这个功能,因为我不想包括整个ng-grid生态系统。 – runtimeZero