question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fxHide or fxShow do not work in <ng-container>

See original GitHub issue

Bug Report

When using te directives fxHide or fxShow in a <ng-container> element inside a body template of a PrimeNG Table like this:

<table>
  <tr *pTemplate="'body'" ...>
    <td>...</td>
   ...
  <ng-container fxHide.lt-md>
     <td>...</td>
    ....
     <td>...</td>
  </ng-container>   
</table>

The following error is shown:

ERROR TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at Function.from (<anonymous>)
    at DefaultShowHideDirective.ngAfterViewInit (show-hide.ts:70)

What is the expected behavior?

No error shown.

What is the current behavior?

The error is shown.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

@angular/core: 9.1.7 @angular/cdk: 9.2.4 @angular/flex-layout: 9.0.0-beta.31

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mrmokwacommented, Jun 10, 2020

I’m not quite sure how flex-layout works under the hood, but it probably takes the directive and apply HTML markup based of it.

In the case of fxHide, it takes the element and sets display:none. ng-container in the other hand, as you said, don’t add a element to the DOM. There’s no element to add the style display:none from fxHide.

Take a look at the example below, the same principe will be applyed.

<div style="background-color: green">
   <ng-container style="background-color: red">
      Foo
   </ng-container>
</div>

image

image

1reaction
mrmokwacommented, Jun 9, 2020

IMO it’s not a bug, ng-container doesn’t get renderered in the html, so the directives won’t apply. Changing ng-container to a div will solve your problems. Obs: Same thing will happen if you specify a class or style in the ng-container.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content is not responsive in flex layout angular - Stack Overflow
First check all the required modules are added in module file then remove the parent div: <div fxFlexFill class="example-container">.
Read more >
Angular Flex Layout: The Masquerade | by Aleix Suau - Medium
In this post I'll summarize the possibilities of flexbox and how Angular Flex Layout enrich and simplifies it with a cool declarative and...
Read more >
How to export data table to pdf using angular material – iTecNote
I have tried to use jsPDF and I found that it works on static data and I want to take ... fxHide fxShow.gt-md>...
Read more >
AngularJS - Bountysource
fxHide and fxShow hide elements via CSS display: none . While CSS-hiding is OK for simple HTML elements, it seems suboptimal for cases...
Read more >
Video 4: Use fxLayout fxLayoutAlign fxFlex fxFlexOrder fxHide ...
... fxLayoutAlign, fxFlex, fxFlexOrder, fxHide and fxShow from Angular Flex Layout Support the ... Your browser can 't play this video....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found