Correct way to use ngFor loop on selector directive? It doesn't seem to work.
See original GitHub issue <div class="cards-flex-container">
<mz-card *ngFor="let Package of packages; last as isLast; odd as isOdd" class="col-12" [class.last-col]="isOdd">
<p><span class="key">Package Name:</span>
<span class="value">{{ Package.Name }}</span>
</p>
<p>
<span class="key">Description:</span>
<span class="value">{{ Package.Description }}</span>
</p>
<p>
<span class="key">Price:</span>
<span class="value">${{ Package.OriginalPackagePrice }}</span>
</p>
<p>
<span class="key">Package Discount:</span>
<span class="value">{{ Package.Discount.Amount * 100 }}%</span>
</p>
<p class="no-margin-bottom">
<span class="key">Package Price:</span>
<span class="value">${{ Package.DiscountedPackagePrice }}</span>
</p>
<!--<hr *ngIf="!isLast" />-->
</mz-card>
</div>
This does not work. It produces blank cards. But if I change
<mz-card *ngFor="let Package of packages; last as isLast; odd as isOdd" class="col-12" [class.last-col]="isOdd">
to
<div *ngFor="let Package of packages; last as isLast; odd as isOdd" class="card-panel col-12" [class.last-col]="isOdd">
It works as expected.
Expected Behavior
Interpolation should work inside of selector directives.
Current Behavior
It doesn’t work.
If this is a big change, I can just continue using regular Materialize, since it doesn’t provide much gain to use the selector directive. But I wanted to bring it to your attention since it might be happening with other selector directives as well.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
angular - *ngIf and *ngFor on same element causing error
I know the easy solution is to move the *ngIf up a level but for scenarios like looping over list items in a...
Read more >How to Use the ngFor Angular Directive - MakeUseOf
The ngFor directive allows you to repeat the same block a specified number of times, or loop through an array of objects to...
Read more >Angular *ngFor and *ngIf Directives Explained for Beginners
Let's talk about *ngFor first. You use the *ngFor directive to traverse over an array object and display the data in the UI....
Read more >Angular Optimization: Use trackBy Option for *ngFor Directive
In the ngDoCheck we use the diff method to detect changes in the items list. If there are changes, we iterate through the...
Read more >Angular ngFor - Learn All Features, Not Only For Arrays
In this post we are going to go over the ngFor core directive, namely we are ... a loop variable named hero is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This will be fixed in our next release.
You need to include your content inside
<mz-card-content>
tag.