How to get the Aurelia ViewModel from a DOM Element

aurelia, javascript

Solution

I believe you're looking for this:

this.element.au.controller.viewModel

Problem

I remember reading some days ago about a method to get the ViewModel of a component let's say, starting from the DOM node. I guess those elements are those that have a `au-target` class on them (added by Aurelia). I've searched on google / documentation but did not manage to find anything. So, how can I get the ViewModel of that element?

Original source