Catalog / Aurelia Cheat Sheet
Aurelia Cheat Sheet
A concise reference for Aurelia, covering core concepts, syntax, and best practices for building modern JavaScript applications.
Core Concepts
Components
Aurelia applications are built from components. Each component consists of a JavaScript view-model and an HTML view. |
View-Model: The JavaScript class that manages the data and behavior for the view. |
File naming convention: |
Data Binding
One-way binding (one-time) |
|
One-way binding (to-view) |
|
One-way binding (from-view) |
|
Two-way binding |
|
Delegate Binding |
|
Trigger Binding |
|
Dependency Injection
Aurelia uses Dependency Injection (DI) to manage dependencies between components. Dependencies are declared in the constructor of the view-model. |
Example:
|
Alternatively, use the
|
Templating
Basic Syntax
Aurelia’s templating engine uses HTML enhanced with custom attributes and elements. String interpolation: |
Attribute binding: |
Event binding: |
Control Flow
|
Loops through a collection.
|
|
Conditional rendering.
|
|
Creates a binding context.
|
Value Converters
Value converters transform data for display in the view. Create a class with |
Example:
|
Usage in view: |
Custom Elements & Attributes
Creating Custom Elements
Custom elements allow you to create reusable UI components with encapsulated logic and presentation. |
Define a class and associate it with an HTML template (view). |
Example:
|
Custom Attributes
Defining |
Custom attributes allow you to extend HTML elements with custom behavior.
|
Usage |
|
Lifecycle Hooks
Aurelia provides lifecycle hooks that allow you to execute code at specific stages of a component’s lifecycle. |
|
Routing
Basic Configuration
Aurelia’s router enables navigation between different views within your application. |
Configure the router in your app’s
|
Add |
Navigation
|
Navigates to a named route with optional parameters. |
|
Navigates to a specific URL. |
|
Creates a navigation link. |
Route Parameters
Access route parameters in your view-model.
|