dinony / od-virtualscroll

🚀 Observable-based virtual scroll implementation in Angular
https://dinony.github.io/od-vsstatic/
MIT License
134 stars 12 forks source link

ngIf not working #11

Closed JacobBrandt closed 6 years ago

JacobBrandt commented 7 years ago

I was unable to get *ngIf statements to work. Anyone else have any success with this?

dinony commented 7 years ago

Hi @JacobBrandt, do you have a minimal plunker to illustrate your issue?

JacobBrandt commented 7 years ago

Just change any demo to use ngIf inside the ng-template tag. It doesn't behave like it should. It doesn't render anything if ngIf is used in this way.

ronzeidman commented 7 years ago

As a workaround, you can create a component and do the *ngIf inside the component

raphdom commented 7 years ago

Not working for me with "ngFor":

<od-virtualscroll [vsData]="innerData" [vsOptions]="options$" class="cells-container" >
   <ng-template let-item let-row="row" let-column="column">
      <div class="column" *ngFor="let ita of item" fxFlex>{{ ita }}</div>
   </ng-template>
</od-virtualscroll>

I can put this in a new component, but this will add complexity in my code

dinony commented 7 years ago

Hey @raphdom, thanks for reporting. I've planned to investigate on this within this milestone.

dinony commented 6 years ago

Sorry, took me a while to get back. Yep, @JacobBrandt, please use the solution suggested by @ronzeidman .

I have no idea why something like this is not possible in Angular:

<ng-template let-item let-row="row" let-column="column">
    <div *ngIf="row % 2 === 0" class="cell">
      <div class="cell-info">
        <span>Even Row: {{row}}</span><br>
        <span>Column: {{column}}</span>
      </div>
      {{item}}
    </div>
    <div *ngIf="row % 2 !== 0" class="cell">
      <div class="cell-info">
        <span>Odd Row: {{row}}</span><br>
        <span>Column: {{column}}</span>
      </div>
      {{item}}
    </div>
</ng-template>

A clue anyone?

@raphdom if you're trying to use Angular flex please check the info here.

MikeKovetsky commented 5 years ago

In my case, the od-virtualscroll throws the error TypeError: Cannot read property 'createEmbeddedView' of undefined with *ngIf="true". Just leaving this comment here for the guys (and google robots) to find the connection between the error and the reason of it.