You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ternary if and parenthesis makes UI not update #814
Reproduced in a clean 1.3.0. Bug was introduced in 1.3.0.
When wrapping a ternary if in a parenthesis (e.g. <Label text="{{ (data === 0) ? 'off' : 'on' }}"/>), the UI does not react to object changes. When writing the same thing without a parenthesis (<Label text="{{ data === 0 ? 'off' : 'on' }}"/>) it works as it should.
However, on first paint/load, it works with the parenthesis. This inconsistency could be the source of bugs and can be very hard to find (believe me and the hours I spent yesterday...).
Example
This example shows a label and two buttons to change the binding context. If bindingContext.data is 0 the label should read 'off', if it is 1 it should read 'on'. When first navigating to the page, it correctly reads 'off' (as the default value of data is 0). If you change the default value of data to 1 it correctly reads 'on'.
Tapping the "On" or "Off" button which changes the binding context does not update the UI. Removing the parenthesis solves the problem.
I'd say that the expected behavior is that it should work both with or without the parenthesis.
Activity
Fixed issue #814.
Merge pull request #869 from NativeScript/nnikolov/Issue814
nsndeck commentedon Oct 5, 2015
Fixed with commit #869.
lock commentedon Aug 30, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.