First we clean up our code by creating a child component and then we use $emit to send data to our parent component.