Skip to content

Instantly share code, notes, and snippets.

@martonsagi
Created November 5, 2016 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martonsagi/b9a2929bdd34061795b90ddbfd745e75 to your computer and use it in GitHub Desktop.
Save martonsagi/b9a2929bdd34061795b90ddbfd745e75 to your computer and use it in GitHub Desktop.
Aurelia - conditional checkbox binding
<template>
<ul>
<li repeat.for="item of items">
<label><input type="checkbox" checked.bind="item.status === 'EnumValue'" /> Checkbox</label>
</li>
</ul>
</template>
export class App {
items = [];
attached() {
for (let i = 0; i < 10; i++) {
this.items.push({status: (i % 2 === 0 ? 'EnumValue' : '')});
}
}
}
<!doctype html>
<html>
<head>
<title>Aurelia</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
</head>
<body aurelia-app>
<h1>Loading...</h1>
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment