Giter VIP home page Giter VIP logo

Comments (5)

JeanMeche avatar JeanMeche commented on June 21, 2024

Your @for doesn't use any element by default where the ngFor directive did.

The equivalent of @for (part of parts; track part) is <ng-container *ngFor="let part of parts"> which exhibits the same issue.

You're probably looking for something like:

  @for (part of parts; track part) {
    <span{{part}}</span>
  }

from angular.

sonikasharma1403 avatar sonikasharma1403 commented on June 21, 2024

@JeanMeche, stackblitz includes the ng-container with ngFor too, but it is not adding any whitespace

image

from angular.

JeanMeche avatar JeanMeche commented on June 21, 2024

What you're seeing is related to the preserveWhitespace option, it's better to keep it on.
To drop any whitespace, you can resort to the comment block trick.

  @for (part of parts; track part) {<!--
  -->{{part}}<!--
  -->}

from angular.

sonikasharma1403 avatar sonikasharma1403 commented on June 21, 2024

Since, we ran migrator on our entire codebase, it is difficult to add comment block trick or span wrappers. Will check out the preserveWhitespace option

from angular.

thePunderWoman avatar thePunderWoman commented on June 21, 2024

So HTML doesn't care about whitespace between HTML elements, but it does in between text nodes. It'll collapse multiple spaces between text nodes into a single whitespace when rendered. So this is happening because the for loop is rendering over multiple text nodes.

The migration auto formatting isn't perfect and can't account for every use case. This seems to be a very rare one. So my suggestion is to just disable the auto formatting for targeted files with this sort of syntax. You'll likely still have some whitespace issues, but it may resolve this one. Detecting this kind of use case would be complicated and the amount of effort to address this rare use case would be high. So I'm going to close this for now since there's workarounds.

from angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.