# How to add a binding behavior from view model?

**URL:** <https://discourse.aurelia.io/t/how-to-add-a-binding-behavior-from-view-model/3135>\
**Category:** Help Requests\
**Created:** [January 5, 2020, 1:50am UTC](https://discourse.aurelia.io/t/how-to-add-a-binding-behavior-from-view-model/3135 "2020-01-05T01:50:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbockle](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jbockle/32/607_2.png) [@jbockle](https://discourse.aurelia.io/u/jbockle)\
**Post date:** [January 5, 2020, 1:50am UTC](https://discourse.aurelia.io/t/how-to-add-a-binding-behavior-from-view-model/3135/1 "2020-01-05T01:50:31Z")

</div>

I’m making a plugin, and I want to add a binding behavior to a bindable property on my custom element instead of requiring others to use the behavior in their templates, is this possible? maybe with `@processContent`?

---

<div class="post-metadata">

**Author:** ![jordan-ware](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jordan-ware/32/1677_2.png) [@jordan-ware](https://discourse.aurelia.io/u/jordan-ware)\
**Post date:** [January 5, 2020, 1:19pm UTC](https://discourse.aurelia.io/t/how-to-add-a-binding-behavior-from-view-model/3135/2 "2020-01-05T13:19:40Z")

</div>

Yes - the property on your view model can be decorated like below:

```auto
import { bindable, bindingMode } from 'aurelia-binding';
...
@bindable({defaultBindingMode: bindingMode.oneTime}) setOnce;

```

I believe the caller can still override this, but if they use the generic `bind` then they’ll get your default configured binding behaviour.  
`<myelement set-once.bind="'test'"></myelement >`

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [January 5, 2020, 1:59pm UTC](https://discourse.aurelia.io/t/how-to-add-a-binding-behavior-from-view-model/3135/3 "2020-01-05T13:59:07Z")

</div>

Very close to what you need.

> **[aurelia-contrib/aurelia-typed-observable-plugin](https://github.com/aurelia-contrib/aurelia-typed-observable-plugin#most-common-usecase)**
>
> An enhanced implementation for observable and bindable decorator of Aurelia - aurelia-contrib/aurelia-typed-observable-plugin

---

<div class="post-metadata">

**Author:** ![jbockle](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/jbockle/32/607_2.png) [@jbockle](https://discourse.aurelia.io/u/jbockle)\
**Post date:** [January 6, 2020, 1:30am UTC](https://discourse.aurelia.io/t/how-to-add-a-binding-behavior-from-view-model/3135/4 "2020-01-06T01:30:35Z")

</div>

I found a good example of how I can achieve this here: [https://github.com/Foursails/aurelia-plus/blob/master/src/type-custom-attribute.js](https://github.com/Foursails/aurelia-plus/blob/master/src/type-custom-attribute.js)
