Struggling to find in the documents a way to do a conditional each statement? (similar to ng-if/ngIf in Angular)
i.e. if some elements in an array of objects have a show=“true” or show=“false” property added to them, how to reflect this in the list
Struggling to find in the documents a way to do a conditional each statement? (similar to ng-if/ngIf in Angular)
i.e. if some elements in an array of objects have a show=“true” or show=“false” property added to them, how to reflect this in the list
If you could be more specific with what you’re trying to accomplish it’d be much easier to help. But here’s a simple example:
<App>
<JavaScript>
var Observable = require('FuseJS/Observable');
var showFirstName = Observable(false);
var names = Observable('Edwin Reynoso', 'John Smith');
var firstNames = names.map(function (fullName) {
return fullName.split(' ')[0];
});
var lastNames = names.map(function (fullName) {
return fullName.split(' ')[1];
});
module.exports = {
showFirstName: showFirstName,
firstNames: firstNames,
lastNames: lastNames
}
</JavaScript>
<StackPanel>
<WhileTrue Value="{showFirstName}">
<Each Items="{firstNames}">
<Text Value="{}" />
</Each>
</WhileTrue>
<WhileFalse Value="{showFirstName}">
<Each Items="{lastNames}">
<Text Value="{}" />
</Each>
</WhileFalse>
</StackPanel>
</App>