jcaddy
jcaddy

Reputation: 501

Aurelia - composing views dynamically

I have a common container component into which I would like to display different components depending on what the user has selected. I have got this working using the element in the container view and binding the view.model attribute to a model property, like this:

  <compose view-model="./${componentName}" if.bind="haveComponent" model.bind="stuff"></compose>

I have methods in the view model which change the value of {componentName} and different views are displayed.It does seem to work but something doesn't feel right, I'm not quite sure.

Is this a legitimate way to achieve this? I'm pretty new to Aurelia so any pointers would be appreciated.

Upvotes: 2

Views: 145

Answers (1)

Alexander Taran
Alexander Taran

Reputation: 6725

That is legitimate use case for compose

Don't be shy and join aurelia's discourse

Upvotes: 1

Related Questions