# Conditional Each Statement

**URL:** <https://forums.fusetools.com/t/conditional-each-statement/5833>\
**Category:** How-to Discussions\
**Created:** [October 7, 2016, 11:41pm UTC](https://forums.fusetools.com/t/conditional-each-statement/5833 "2016-10-07T23:41:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![magellen](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@magellen](https://forums.fusetools.com/u/magellen)\
**Post date:** [October 7, 2016, 11:41pm UTC](https://forums.fusetools.com/t/conditional-each-statement/5833/1 "2016-10-07T23:41:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Edwin\_Reynoso](https://avatars.discourse-cdn.com/v4/letter/e/e99b99/32.png) [@Edwin\_Reynoso](https://forums.fusetools.com/u/Edwin_Reynoso)\
**Post date:** [October 8, 2016, 5:11am UTC](https://forums.fusetools.com/t/conditional-each-statement/5833/2 "2016-10-08T05:11:00Z")

</div>

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:

```auto
<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>

```
