I'm trying to figure out how to store a "global" like function in Aurelia. I've followed this tutorial "http://blog.durandal.io/2015/04/24/aurelia-custom-elements-and-content-selectors/" to open a modal with a dynamic view modal, but I can't figure out where I should actually put this function so I can re-use it all my view routes.
I've created this function in my default view:
//open modal
setModal(modal) {
this.contentModal = modal;
$('.modal').modal();
}
with this markup inside that view template:
<a click.delegate="setModal('users')">Test</a> <a click.delegate="setModal('child-router')">Test 2</a>
<modal>
<modal-header title.bind="'View Person'"></modal-header>
<modal-body content.bind="contentModal"></modal-body>
<modal-footer buttons.bind="['Cancel']"></modal-footer>
</modal>
And I can call it via click.delegate="setModal('users')
inside that view template, but I can't figure out how to actually make this available outside of this view template.
Sorry I'm very new to this framework!