-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*ngIf not working in Angular application for hide/show layout after upgrade to NS3 #872
Comments
I'm having some similiar issues with *ngIf, sometimes the elements are rendered out of order, sometimes aren't even rendered. Seems to be related with the last version (3.1.0). |
Me to, not only with *ngIf but *ngFor too |
I have found |
Same here. |
I also have a similar issue, where after a http request and setting a boolean to true to show content, the content doesnt show. But what prompted me top try this, was the http request returns a string which is supposed to change a labels text but it didnt change. That is why I wrapped it in a ngIf but then it doesnt show at all. |
After I did the upgrade and had to redo my Angular layout logic I've found these issues with ngIf:
Overall it was unpleasant to find out that what used to work with {N}2.5 is not working in {N}3.x. |
A possible workaround for out-of-order rendering could be separating the elements in different <StackLayout>
<GridLayout id="g1" *ngFor>
</GridLayout>
<GridLayout id="g2">
</GridLayout>
</StackLayout> Because of the This fixed it: <StackLayout>
<StackLayout>
<GridLayout id="g1" *ngFor>
</GridLayout>
</StackLayout>
<StackLayout>
<GridLayout id="g2">
</GridLayout>
</StackLayout>
</StackLayout> |
@EddyVerbruggen Your workaround resolved my issue with multiple *ngIf items better than the visibility workaround. Thanks! |
Hey, guys! Can you share some code snippets where items are rendered out of order? |
Hi @sis0k0, here's one I hope you find useful: <StackLayout>
<!-- NOK -->
<StackLayout>
<Label text="label 1"></Label>
<Label text="label 2"></Label>
<Label text="label 3" *ngIf="true"></Label>
<Label text="label 4"></Label>
</StackLayout>
<!-- OK -->
<StackLayout>
<Label text="label a"></Label>
<Label text="label b"></Label>
<StackLayout>
<Label text="label c" *ngIf="true"></Label>
</StackLayout>
<Label text="label d"></Label>
</StackLayout>
</StackLayout> |
This issue was initially not about out-of-order rendering. It is about elements, where *ngIf is changed dynamically after the first render of the page, not getting rendered at all. This problem does and still only occur on iOS. Code examples on Version 3.2.0:
Leads to not rendering when toggling for the first time, but toggling back renders the elements again! All in all this issue should not have been closed, because the problem persists, elements with *ngIf are not rerendered when their values are changed dynamically. |
@cgebe Same here, but I'm experiencing on Android. |
I found out, this issue only happens in conjuction with RadListView due to not using ObservableArray as underlying data structure. |
+1 |
+1 Still having this issue, both *ngFor and *ngIf don't re-render for iOS correctly when data changes after the initial render |
Also seeing this issue on IOS for *ngIf |
+1 |
Any update on this issue, it still persists.... By the way, I'm using the last version of nativescript and nativescript-angular. |
Issue should be reopened. |
Heya, could you please share a playground link or some code snippet that demonstrates the broken behavior? |
It seems to me that:
So in this example, I have a menu which I would like to toggle and if menuStatus is true at the beginning it works, however, if it's false then some sort of UI refresh is needed to make the visibility work. But obviously when you have such menu you'd most likely want it to be hidden at first so I'm struggling with this a little. I should probably mention that this snippet is in a RadListView as well. Is there an update on this? |
So there is no quick fix for this? Like some fix on config files or something like that? |
@behrangs Did you resolve that issue somehow? I'm exactly facing the same. :( |
Same issue here. I hope they re-open this issue. |
@netowp @yasserN @svzi @Raf197 @behrangs the issue seems to be related to this one. The fix for the linked issue is already in
Keep in mind that the |
NickIliev got it right. I had the problem with the following html on android only and broken on IOS. however after upgrading it works. Thanks for your assistance |
hey @NickIliev that was really helpful im really struggling with this issue for days. |
I feel like this needs to be re-opened again, how it possible that I'm still seeing this issue in {N} 4.1.1 with tns-core-modules@next (^4.2.0-2018-07-21-02). Same with ngSwitch and [visibility] also does not work as expected. I have yet to find a workaround
Neither version works to show the progress bar when location.progress is updated. I can see location.progress updating in the UI via a simple |
Here's a playground to demonstrate the issue which is still present in {N} 4.1 https://play.nativescript.org/?template=play-ng&id=xRtLDX&v=4 The top section does now show the progress bar when u start the "upload", meanwhile the bottom section does. The only difference between these 2 ListViews is that in the top case I pass the countries reference via I have tried the same implementation with a GridView (instead of ListView) so it seems evident that the problem really arises when using *ngIf or *ngSwitch inside an *ngFor that is iterating over an array reference. Can somebody please take a look into fixing this. Since passing an array reference is actually the correct way to use ngFor, it seems that this is a very common and rudimentary use case and it's a real bummer to have this present after 1 year of this issue being open. I currently have no workaround for this, as I would just be trading one bug for another (I have to choose between a progress bar and image jitter/constant reloads). |
Still in NS 4+, I found that using |
When I bind a function to the *ngIf instead of binding an attribute, it works fine, except for the "Expression has changed after last checked" error. |
Thanks @kamok this solution worked for me. This seems to be the simplest temporary workaround that I have seen in the thread. The update to the tns core modules didn't work for me as well. |
I face the same issue, but found another work around (works for me, but no guarantees...). |
I was very excited to learn Ionic, sadly landed on Ionic 4 which seems overly unstable right now! For me, |
Any updates on this issue? |
For me, this is still an issue. Can't really use |
also having trouble with *ngIf, its rendering my element outside of parent element |
For me this wasn't working because I'd missed the inclusion of some declarations under @NgModule in app.module.ts:
|
I have also problem with ngIf inside a p-splitter template. If I move the splitter, the ngIf seams to be ignored and all the code will be placed in the dom. |
yes i have same issue in ios app only so i added ngZone this one solved my problem for ios app.
|
From @memphisvl on June 29, 2017 19:56
It used to work on {N} 2.5 and now it seems that the only way to show/hide some elements is using visibility option.
Before
Now (Workaround)
Is this expected and from now on I will have to use visibility for UI logic?
Versions
TNS Paltform
3.1.0
Copied from original issue: NativeScript/NativeScript#4479
The text was updated successfully, but these errors were encountered: