Sergey Stadnik
Sergey Stadnik

Reputation: 3218

How to trigger an action in a child Angular 1.5 component?

I have an Angular 1.5 component with another enclosed child component. What is the best way to trigger an action in the child controller from the parent and pass a payload as a parameter?

I know I can watch for a change of a data item via the child's $onChange lifecycle hook, but I would prefer a "push" abstraction (like calling a child's method from the parent) rather than "pull" abstraction (like child reacting to a change of the paren's property).

Upvotes: 2

Views: 174

Answers (1)

neha soni
neha soni

Reputation: 221

You can use $broadcast for this. It should solve the purpose.

Upvotes: 2

Related Questions