Skip to content

Instantly share code, notes, and snippets.

@lstarky
Last active February 12, 2017 23:23
Show Gist options
  • Save lstarky/20495ff4f507472936b0ae5c99058bac to your computer and use it in GitHub Desktop.
Save lstarky/20495ff4f507472936b0ae5c99058bac to your computer and use it in GitHub Desktop.
Displaying the Json result in Table with some logic
<template>
<div class="container-fluid">
<h1>Table Method</h1>
<table width="100%">
<td>
<div repeat.for="field of myData" if.bind="field.order % 2">
<p><b>${field.Key}:</b> ${field.value}</p>
</div>
</td>
<td>
<div repeat.for="field of myData" if.bind="!(field.order % 2)">
<p><b>${field.Key}:</b> ${field.value}</p>
</div>
</td>
</table>
<h1>Bootstrap Method (Responsive)</h1>
<p><i>The second column will wrap down below on smaller screens... if you see it in one column, try widening the screen</i></p>
<div class="row">
<div class="col-xs-6">
<div repeat.for="field of myData" if.bind="field.order % 2">
<p><b>${field.Key}:</b> ${field.value}</p>
</div>
</div>
<div class="col-xs-6">
<div repeat.for="field of myData" if.bind="!(field.order % 2)">
<p><b>${field.Key}:</b> ${field.value}</p>
</div>
</td>
</div>
</div>
</template>
export class App {
myData = [{"Key":"Name","value":"Sriram","order":"01"},{"Key":"Email","value":"sriram@gmail","order":"02"},{"Key":"Genader","value":"male","order":"03"},{"Key":"DOB","value":"01-01-88","order":"04"},{"Key":"MobileNo","value":"999999999","order":"05"},{"Key":"Address","value":"","order":"06"}];
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body aurelia-app="main">
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script>
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script>
<script>
require(['aurelia-bootstrapper']);
</script>
</body>
</html>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging();
aurelia.start().then(() => aurelia.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment