R
R
rakro2016-02-15 11:52:27
Angular
rakro, 2016-02-15 11:52:27

Components in Angular?

There are parent and child components. If you need to call the function of the parent component from the child, then it needs to be passed through bindings. What if you need to do the opposite, call a function from the parent that is declared in the controller of the child component?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2016-02-15
Protko @Fesor

from the parent to call the function that is declared in the controller of the child component?

Think about where something went wrong. The parent component should not want anything from its children. All he can do is change the data he passes through the bindings. In this case, it's enough to simply make a setter (via defineProperties or just a setter if you're using babel) on the controller's child directive.

I
Ilya-Karev, 2016-06-30
@Ilya-Karev

You can use the $onChanges function - in the second angular, the analogue is used everywhere. Note that it only works with one-way bindings.
blog.thoughtram.io/angularjs/2016/03/29/exploring-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question