Accessing the Aurelia viewModel from the browser

If you want to accessing the Aurelia viewModel from the browser console, note that there’s a difference between the element hosting the Aurelia app itself, and an element hosting an Aurelia component. If the app is hosted on the body element (<body aurelia-app="main">) you can use;

document.querySelector('body').aurelia.container.viewModel or

and in the component case, you can find the viewModel via


Leave a Reply

Close Menu