Ember Octane vs Aurelia 2 Comparison

Reactivity

Declare state

Ember Octane

name.hbs

<h1>Hello {{this.name}}</h1>

Aurelia 2

name.html

<h1>Hello ${name}</h1>

Update state

Ember Octane

name.hbs

<h1>Hello {{this.name}}</h1>

Aurelia 2

name.html

<h1>Hello ${name}</h1>

Computed state

Ember Octane

double-count.hbs

<div>{{this.doubleCount}}</div>

Aurelia 2

double-count.html

<div>${doubleCount}</div>

Templating

Minimal template

Ember Octane

hello-world.hbs

<h1>Hello world</h1>

Aurelia 2

hello-world.html

<h1>Hello world</h1>

Styling

Ember Octane

css-style.css

/* using: https://github.com/salsify/ember-css-modules */
.title {
  color: red;
}

Aurelia 2

css-style.css

.title {
  color: red;
}

Loop

Ember Octane

colors.hbs

<ul>
  {{#each (array "red" "green" "blue") as |color|}}
    <li>{{color}}</li>
  {{/each}}
</ul>

Aurelia 2

colors.html

<ul>
  <li repeat.for="color of colors">${color}</li>
</ul>

Event click

Ember Octane

counter.hbs

<p>Counter: {{this.count}}</p>
<button {{on "click" this.incrementCount}}>+1</button>

Aurelia 2

counter.html

<p>Counter: ${count}</p>
<button click.trigger="incrementCount">+1</button>

Dom ref

Ember Octane

input-focused.hbs

<input {{this.autofocus}} />

Aurelia 2

input-focused.html

<input ref="inputElement" />

Conditional

Ember Octane

traffic-light.hbs

<button {{on "click" this.nextLight}}>Next light</button>
<p>Light is: {{this.light}}</p>
<p>
  You must
  {{#if (eq this.light "red")}}
    STOP
  {{else if (eq this.light "orange")}}
    SLOW DOWN
  {{else if (eq this.light "green")}}
    GO
  {{/if}}
</p>

Aurelia 2

traffic-light.html

<button click.trigger="nextLight()">Next light</button>
<p>Light is: ${light}</p>
<p switch.bind="light">
  You must
  <span case="red">STOP</span>
  <span case="orange">SLOW DOWN</span>
  <span case="green">GO</span>
</p>

Lifecycle

On mount

Ember Octane

page-title.hbs

<p>Page title is: {{(this.pageTitle)}}</p>

Aurelia 2

page-title.html

<p>Page title is: ${pageTitle}</p>

On unmount

Ember Octane

time.hbs

<p>Current time: {{this.time}}</p>

Aurelia 2

time.html

<p>Current time: ${time}</p>

Component composition

Props

Ember Octane

app.hbs

<UserProfile
  @name="John"
  @age={{20}}
  @favouriteColors={{array "green" "blue" "red"}}
  @isAvailable={{true}}
/>

Aurelia 2

app.html

<user-profile
  name.bind
  age.bind
  favourite-colors.bind="colors"
  is-available.bind="available"
></user-profile>

Emit to parent

Ember Octane

app.hbs

<p>Are you happy?</p>
<AnswerButton @onYes={{this.handleYes}} @onNo={{this.handleNo}} />
<p style="font-size: 50px;">{{if this.isHappy "😀" "😥"}}</p>

Aurelia 2

app.html

<p>Can I come ?</p>
<answer-button action-handler.bind="handleAnswer"></answer-button>
<p style="font-size: 50px">${isHappy ? "😀" : "😥"}</p>

Slot

Ember Octane

app.hbs

<FunnyButton> Click me! </FunnyButton>

Aurelia 2

app.html

<funny-button>Click me !</funny-button>

Slot fallback

Ember Octane

app.hbs

<FunnyButton />
<FunnyButton>I got content!</FunnyButton>

Aurelia 2

app.html

<funny-button></funny-button> <funny-button>Click me !</funny-button>

Context

Ember Octane

app.hbs

<UserProfile />

Aurelia 2

app.html

<h1>Welcome back, {{ user.username }}</h1>
<user-profile />

Form input

Input text

Ember Octane

input-hello.hbs

<p>{{this.text}}</p>
<input value={{this.text}} {{on "input" this.handleInput}} />

Aurelia 2

input-hello.html

<p>${text}</p>
<input value.bind />

Checkbox

Ember Octane

is-available.hbs

<input
  id="is-available"
  type="checkbox"
  checked={{this.isAvailable}}
  {{on "change" this.handleChange}}
/>
<label for="is-available">Is available</label>

Aurelia 2

is-available.html

<input id="is-available" type="checkbox" checked.bind="isAvailable" />
<label for="is-available">Is available</label>: ${isAvailable}

Radio

Ember Octane

pick-pill.hbs

<div>Picked: {{this.picked}}</div>

<input
  id="blue-pill"
  type="radio"
  value="blue"
  checked={{eq this.picked "blue"}}
  {{on "change" this.handleChange}}
/>
<label htmlFor="blue-pill">Blue pill</label>

<input
  id="red-pill"
  type="radio"
  value="red"
  checked={{eq this.picked "red"}}
  {{on "change" this.handleChange}}
/>
<label htmlFor="red-pill">Red pill</label>

Aurelia 2

pick-pill.html

<div>Picked: ${picked}</div>

<input id="blue-pill" checked.bind="picked" type="radio" value="blue" />
<label for="blue-pill">Blue pill</label>

<input id="red-pill" checked.bind="picked" type="radio" value="red" />
<label for="red-pill">Red pill</label>

Select

Ember Octane

color-select.hbs

<select {{on "change" this.select}}>
  {{#each this.colors as |color|}}
    <option
      value={{color.id}}
      disabled={{color.isDisabled}}
      selected={{eq color.id this.selectedColorId}}
    >
      {{color.text}}
    </option>
  {{/each}}
</select>

Aurelia 2

color-select.html

<select value.bind="selectedColorId">
  <option value="">Select A Color</option>
  <option
    repeat.for="color of colors"
    value.bind="color.id"
    disabled.bind="color.isDisabled"
  >
    ${color.text}
  </option>
</select>

Webapp features

Render app

Ember Octane

index.html

<!DOCTYPE html>
<html>
  <head>
    <script type="module" src="./app.js"></script>
  </head>

  <body>
    <x-app />
  </body>
</html>

Aurelia 2

index.html

<!DOCTYPE html>
<html>
  <head>
    <script type="module" src="./main.ts"></script>
  </head>

  <body>
    <app></app>
  </body>
</html>

Fetch data

Ember Octane

app.hbs

{{#let (this.fetchUsers) as |request|}}
  {{#if request.isLoading}}

    <p>Fetching users...</p>

  {{else if request.error}}

    <p>An error occurred while fetching users</p>

  {{else}}

    <ul>
      {{#each request.users as |user|}}
        <li>
          <img src={{user.picture.thumbnail}} alt="user" />
          <p>{{user.name.first}} {{user.name.last}}</p>
        </li>
      {{/each}}
    </ul>

  {{/if}}
{{/let}}

Aurelia 2

app.html

<template promise.bind="useFetchUsers.fetchData()">
  <p pending>Fetching users...</p>
  <p catch>An error ocurred while fetching users</p>
  <ul then.from-view="users">
    <li repeat.for="user of users">
      <img src.bind="user.picture.thumbnail" alt="user" />
      <p>${ user.name.first } ${ user.name.last }</p>
    </li>
  </ul>
</template>






Decouvrez plus d’Offres de la plateform ItGalaxy.io :

Découvrez notre gamme complète de services et formations pour accélérer votre carrière.

1. Nous contactez

  • Description: Besoin de Formation et des Solutions cloud complètes pour vos applications
  • Links:

2. Infra as a Service

  • Description: Infrastructure cloud évolutive et sécurisée
  • Links:

3. Projets Développeurs


4. Développeurs


5. Formations Complètes


6. Marketplace

7. Blogs


This website is powered by ItGalaxy.io