Example of Binding Inheritance

This was in the October release notes, does anyone have a simple example of how it can be used?

Inheritance of Bindables - Now you can inherit custom elements to inherit the bindable properties! This addresses the most common request for basic component inheritance scenarios.

I have come custom elements which have some bindable properties that are the same but the templates aren’t.

1 Like

You’ll found more info here:

A simple example along your description is this:

class BaseBehavior {
  @bindable frob = 4;
  @bindable bar = 2;

export class OneCustomElement extends BaseBehavior {

export class AnotherCustomElement extends BaseBehavior {

Here is another example of using inheritance with Aurelia bindable:

class hierarchy:

  • FieldBehavior
    • TriggerField
      • NumberField
      • SelectField

The SelectField also has an override-able class method to provide template for the list, so you can override it right there, or in its sub classes