我使用transclude:true在angular js中创建了一个指令,并将replace:true替换为
.directive('customElement', [function(){
return {
restrict: 'E',
template: '<table class="table table-striped table-bordered table-hover dataListing"><tbody ng-transclude></tbody></table></div>',
replace: true,
scope: {
tableCaption : "@",
colsName : "=",
tableData : "="
},
transclude: true,
link: function(scope, elem, attrs) {
console.log(scope.colsName);
}
};
}]);
并在html中我称之为
<custom-Element table-Caption="Port Listing" cols-Name="tableColumns" table-Data="portList.emulationDetails">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
</tr>
</custom-Element>