0

take simple 'list' component and 'list-item component'. I will click 'update' @output function at 'list-item' component, but since emitter is 'void' I have no way of getting information that item was saved or not, and 'list-item' detail can be closed.

In angular 1, I can just bind & callback returning promise, and do detail close on .then() inside Child component. How can I reach same goal of letting one of child components know that it was saved?

Jiro Matchonson
  • 875
  • 1
  • 17
  • 24
  • I know about, https://stackoverflow.com/questions/35328652/angular-pass-callback-function-to-child-component-as-input but it only shows some 'hacky?' way to do that + there is no example with also passing parameters. What is the expected best practice way to implement this? I definitely do not want ajax calls directly in child component. – Jiro Matchonson Aug 29 '18 at 23:16
  • If I understood what you want, can't you just put a boolean Input 'saved' to know if it has been saved or not? – Powkachu Aug 30 '18 at 09:03
  • Hello, I would have to pass that down components tree, and it can be an error which I would have to pass as another value down to the tree, and would need another ones for deleting items, really troublesome. Funny is I started 2 projects one on Agular 1 and another on angular 6 at same time (was working on Ember 2 before - that one is best on market really), so I am also solving very simillars problems on both projects, and must say Angular 1 is much more realiable/solid than 6 is, but thats just personal thought. – Jiro Matchonson Aug 30 '18 at 10:27
  • Look at [this](https://stackoverflow.com/questions/35328652/angular-pass-callback-function-to-child-component-as-input) post, maybe it can help? – Powkachu Aug 30 '18 at 10:39
  • Thats one i mentioned in first comment :), there is no example of binding this with parameters and its some kind of hack more or less. And accepted answer is telling that its impossible. – Jiro Matchonson Aug 30 '18 at 10:48
  • At the moment am thinking about using service , but I would have to pass component another variables which is does not need to know to be able make the calls :( – Jiro Matchonson Aug 30 '18 at 10:54

0 Answers0