0

I have created a directive in angular js with transclude: true, and replace: true as below

.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);
            }
        };
        }]);

and in the html i am calling it as

<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>

but when I run this code the transcluded data (table rows) is get converted into a span and placed into the directive as shown in the image belowsee the highlighted area

atul
  • 552
  • 4
  • 16
  • Please go through [this answer](http://stackoverflow.com/a/33551496/2435473) & [this](http://stackoverflow.com/a/34443982/2435473) one. Basically `table` can't have element other than `table` elements in `table`'s element, only `th` & `td` can have all html element inside it – Pankaj Parkar Aug 29 '16 at 10:29
  • You could look at [this answer](http://stackoverflow.com/a/33981573/2435473) as well – Pankaj Parkar Aug 29 '16 at 10:41

0 Answers0