What is the reason behind the cell separation (double borders) in a table when using transclude in AngularJS?

Learn the directive below that generates a table with four columns:

app.directive('tableWrapper',function() {
  return {
    restrict: 'E',
    transclude: true,
    template: '<table><ng-transclude></ng-transclude></table>',
  }
});

app.directive('myCells',function() {
  return {
    restrict: 'E',
    template: '<tr><td>Name</td><td ng-repeat="c in [1,2,3]">{{c}}</td></tr>',
  }
});

View the html code on Plunker: http://plnkr.co/edit/ZTrSifnYWKaNy9XQzfGL

<table><tr><td>Name</td><td ng-repeat="c in [1,2,3]">{{c}}</td></tr></table>
<hr/>
<table-wrapper><my-cells></my-cells></table-wrapper>

Both tables are identical visually, but the second one, due to transclusion, has separate cells.

Instead of: |Name|1|2|3|
The second one displays: |Name||1||2||3|
Where || represents a thick border between adjacent cells.

Why does this happen?
Is there a solution?

Answer №1

The transclude 'table' does not include the CSS property border-collapse: collapse because it doesn't adhere to the

table{
    border-collapse: collapse
}

guidelines in the normalize.less file

If you examine the dom structure below, you'll understand why. Your transclude 'table' is being displayed as a table-wrapper element rather than an actual table.

https://i.sstatic.net/wMgj5.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Getting the present location on Google Maps for the web: A step-by-step guide

As a newcomer to this API, I have successfully generated an API key but am unsure of how to implement Google Maps. Despite my extensive research, I have been unable to find a solution that works for me. I am seeking assistance in locating users or devices ...

CSS, the vertical alignment feature is not functioning properly in Mozilla Firefox

Creating a webpage with fixed height header and footer, and a contentWrapper div in between that stretches to the maximum screen height. The content div inside the contentWrapper needs to be vertically and horizontally aligned within its parent div. This s ...

Diverse model schemas within an array of models in AngularJS

Working on an angularjs project, I encountered a challenge that has stumped me. The issue lies within a controller containing an array representing various exams. function ExamCtrl($scope) { $scope.exams = [{ "title" : "Some fancy title", ...

Employing random runtime strings for the placement of Tailwind CSS classes

Is there a way to define the position of a div using runtime data? Would setting the className string through some hook be the solution? I often encounter issues with asynchronous operations causing this type of problem. I was hoping someone could guide m ...

Is there a potential white-space issue with jQuery CSS in Internet Explorer versions 7 and 8

Recently, we encountered an unusual issue with jQuery and CSS while working on compatibility with IE7 and IE8. Our project involves animations and height measurements, and during the animations, we wanted to prevent text from wrapping. To achieve this, we ...

Comparison: CSS3 versus Angular Material CSS

My ul and li design in CSS is functioning perfectly on Bootstrap. However, when I apply the same code to an Angular Material project, the Angular Material CSS seems to be overriding my styles. CSS Code: li { width: 2em; height: 2em; text-alig ...

Using $http in the Tour of Heroes Component

Currently, I have the Tour of Heroes application up and running, but now I want to enhance it by making AJAX calls. I have set up a WebAPI service that delivers the data with CORS enabled. To test this, I created a simple non-Angular client using JQuery $ ...

The functionality of making Slim POST requests is currently not functioning as expected within the Ionic

An issue is arising with my app that makes calls to a REST API using POST and GET methods. The app I'm developing with Ionic works perfectly when emulated using the command: ionic serve --lab However, when running the app on an actual device, calls ...

There seems to be an issue with the angular login feature using ui-router, as it is not able

Implementing a custom login module for my website as shown below: angular.module('caknow', [ 'ui.router', 'ngStorage', 'authentication', 'login' ]) .config(['$stateProvider', '$url ...

Select the elements that are positioned every fourth or fifth, ninth or tenth, and fourteenth or fifteenth in the set

I'm currently designing a blog layout and I'm looking to implement a feature where every 4th and 5th, 10th and 11th, 14th and 15th, etc. post will have a unique class assigned to it. The pattern I am aiming for is to have 3 regular posts followe ...

Controlling the position of a <div> element using JavaScript

Is there a way to adjust the position and size of a <div>? I have already set it to float with this CSS code: div.grid_tooltip { position: absolute; left: 0px; top: 0px; } ...

Is it possible to highlight only a specific color on the div background?

I'm trying to create a layout similar to this: https://i.sstatic.net/dZ1ka.png I've managed to get most of it working, but I'm struggling with the yellow rectangle that spans the background of the screen. Currently, it looks like this: https ...

Having trouble assigning a property to a controller within an Angular Material modal dialog

My current setup involves Angular 1.5, ES6, and webpack. Here's a snippet of my code: export default class HomeController { static $inject = ['$mdDialog', '$sce']; constructor($mdDialog, $sce) { this.$mdDialog = $mdDialog ...

Strategies for reducing the amount of space between cards in Bootstrap 4

After creating 4 cards using Bootstrap version 4.5, I noticed that the spacing is not right. I'm struggling to reduce the spacing between the cards. Have a look at the image below if you're still confused: https://i.sstatic.net/RrJLL.jpg .car ...

Avoiding line breaks for a div positioned on the right within a flexible container

My current design consists of a red bar inside a container that is positioned between two black boxes. The size of the boxes remains fixed, while the red bar and container are both based on percentages. I am aiming to decrease the size of both the contain ...

Change the background color according to the user's input text

I want to create a text box where users can input color keywords like blue, lime, or black. When they click submit, I want the background color of the page to change accordingly. This is what I have so far: <label for="color">Color: </label> ...

The correct CSS file did not load, as it appears that another file from a different location has been

Currently facing an issue with my website. The CSS file located at css/style.css is empty, but it is not loading when the index.php in public_html on cPanel loads. I have added the following link: link rel='stylesheet' type='text/css' ...

Creating a div that overlays other divs using html and css

On websites like Facebook and LinkedIn, there is a search box where you can type in your query and the results will display below it, covering up other content on the page. This functionality is shown in the screenshot below from LinkedIn. I am curious ab ...

Enhance the vertical size of IcoFont

This code snippet includes CSS for styling a navbar, as well as HTML and Angular directives for creating navigation elements. If you're looking to center the <li> tags within the <nav> elements and increase the size of their IcoFont icons ...

AngularJS "Constant" Service

Currently, I am in the process of configuring files in AngularJS. Is there a way to create a factory in AngularJS that cannot be overridden? For instance, setting up a constant like the following: module.constant('animals', {"cat": "meow", "do ...