How to get Aurelia to destroy / recreate a view / viewModel pair without using a router

It was unexpected when we started with Aurelia, which if.binddoes not destroy the child view / viewModel. It goes through a bound / untied attached / disconnected loop, and I see how this makes sense for some scenarios. But I would also like to completely destroy the view / viewModel and recreate it from scratch. I created a plunker that demonstrates my best efforts using if.bind. I am looking for suggestions on how to have <my-other-element> completely destroyed. Thank!

+4
source share
1 answer

It looks like you can use the element <compose>to handle the custom element as a view / presentation model and therefore use the transient creation behavior. See documentationcompose

plunker: https://plnkr.co/edit/vKsQsHKsIp4vTVjG5G7f?p=preview

<template if.bind="someBoolean">
  <compose view-model="my-other-element.js"></compose>
</template>
+1
source

Source: https://habr.com/ru/post/1654514/


All Articles