order of angular controller's initialisation
javascriptangularjs
tomoyukikashiro
Outline
Angular controllers are initialized from parent to child.
So child controllers can not get any event from parent controller when parent controller is initialized.
Detail
This is simple sample.
Controller’s code is really simple. They outpu their name in conole after initialized.
In this sample, controller are declared from thirdController
, secondController
, firstController
in order.
But their names outputed in conole are bellow.
"init firstController"
"init secondController"
"init thirdController"
Because Angular controller are initialized from parent dom to child dom regardless of the declared order.
So be careful childredn controllers (thirdController, secondController
) can not get any event from parent controller when parent controller is initialized (child controllers are not initialized).