-
-
Save floydpink/21991c490810a4acf2e38cec99614bbd to your computer and use it in GitHub Desktop.
How to conditionally display client-side data with Aurelia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<ul> | |
<li repeat.for="obj of data" if.bind="obj.customDataType"> | |
<span>${obj.customDataType.cdt}</span> - | |
<strong repeat.for="cda of obj.customDataArray">${cda}, </strong> | |
</li> | |
<li repeat.for="obj of data" if.bind="!obj.customDataType"> | |
<span>No CustomDataType</span> - | |
<strong repeat.for="cda of obj.customDataArray">${cda}, </strong> | |
</li> | |
</ul> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App { | |
data = [{ | |
objectID: 1, | |
customDataArray: [1, 2, 3, 4], | |
customDataType: { | |
cdt: "Troops" | |
} | |
},{ | |
objectID: 2, | |
customDataArray: [11, 22, 33, 44], | |
customDataType: { | |
cdt: "Artilleries" | |
} | |
},{ | |
objectID: 3, | |
customDataArray: [21, 32, 43, 54] | |
}]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment