I start learning the first angular and for a long time stuck on the problem of buying. Immediately attach all your code: https://plnkr.co/edit/irj9iZiWYY6ctZph3Cwb
By the structure of the project, it is clear that the parent component outputs data, and the child component (being a parent dependency) performs the role of adding new data.
The method of adding new data remains in parent, since This component of mine is considered “smart” and stores data.
<child-add on-add="$ctrl.appendData()" /> In the child element, I pass this callback to call it when submitting the form for adding new data. In the child.component.js file in the onSubmit function onSubmit I want to call ctrl.onAdd , but as I understand it, I cannot send new data there with an argument ( read here )
Question: how then to transfer data from child to parent component? I want to immediately learn how to do it right.
And one more thing: if I don’t use ES6 syntax (classes), do I design the code correctly? Is it worth this call ctrl to use it in functions? Functions like onSubmit worth writing right inside the controller function?
Thank.