Making OWL components with hooks
OWL is a powerful framework and supports automatic updates for the UI based on hooks. With update hooks, a component’s UI will be automatically updated when the internal state of the component is changed. In this recipe, we will update the message in the component based on user actions.
Getting ready
For this recipe, we will continue using the my_hostel
module from the previous recipe.
How to do it…
In this recipe, we will add arrows around the text in the component. When we click on the arrow, we will change the message. Follow these steps to make the OWL component reactive:
- Update the XML template of the component. Add two buttons with an event directive around the text. Also, retrieve the message dynamically from the list:
static template = xml` Â Â Â Â <div class="bg-info text-white text-center p-3"> Â Â Â Â Â Â Â Â <i class="fa fa-arrow-left...