Created
April 27, 2016 23:44
-
-
Save jsobell/42089c87fcb30e36ce02a09bac9bd310 to your computer and use it in GitHub Desktop.
Aurelia simple repeat
This file contains hidden or 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> | |
| <a href="#!" click.delegate="selectUser(user.id)" class="collection-item ${user.state}" repeat.for="user of users" id="user-${user.id}"> | |
| <span if.bind="!user.lastName">${user}</span> | |
| <span if.bind="user.firstName">${user.lastName}, ${user.firstName}</span> | |
| </a> | |
| </template> |
This file contains hidden or 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 { | |
| users = [ | |
| { id: 1, firstName: 'Rob', lastName: 'Eisenberg' }, | |
| { id: 2, firstName: 'Jeremy', lastName: 'Danyow' }, | |
| { id: 3, firstName: 'Matt', lastName: 'Broadst' }]; | |
| selectUser(userId) { | |
| let user = this.users.find(u => u.id == userId); | |
| user.state = 'active'; | |
| } | |
| } |
This file contains hidden or 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"> | |
| <link rel="stylesheet" href="styles.css"> | |
| <script> | |
| var _setTimeout = window.setTimeout.bind(window); | |
| window.setTimeout = function(f, t) { | |
| if(t > 0) | |
| { | |
| return _setTimeout(f, t); | |
| } | |
| else | |
| { | |
| return window.setImmediate(f); | |
| } | |
| }; | |
| </script> | |
| </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> |
This file contains hidden or 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
| a { | |
| display: block; | |
| } | |
| a:link { | |
| color: black; | |
| text-decoration: none; | |
| } | |
| .collection-item | |
| { | |
| background: lightgray; | |
| } | |
| /* since you set background property on .collection-item, this style must come after .collection-item otherwise it's not applied */ | |
| .active { | |
| background: blue; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment