Aurelia: changing the name (attribute) of the binder

I want to know if it is possible to change the name (attribute name in HTML) of the binder in Aurelia. Due to the coding standards that we use in my current project, names of the attributes that we use, it is very ugly, for example m-data="someData". We prefix all class members with m. I know I can use it for a class, so custom element names are customizable, but can I also do this for binders?

For instance:

// my-component.js

// I can use a decorator here to
// change the custom element name, which is great!
@customElement('my-component')
export class clsMyComponent {
  @bindable mData;
}

This leads to the following:

<!-- index.html -->

<my-component m-data.bind="someData"></my-component>

So what I want to do, but does not work, is:

@customElement('my-component')
export class clsMyComponent {
  @bindable({name: 'data'}) mData;
}

I could not find anything, I know that you can set things like two-way binding, default value, etc. But not right? Any help would be appreciated!

+4
1

, . Aurelia docs ( " " ). :

@customElement('my-component')
export class clsMyComponent {
  @bindable({attribute: 'data'}) mData;
}

HTML:

<my-component data.bind="someData"></my-component>
+6

Source: https://habr.com/ru/post/1677817/


All Articles