Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

order of angular controller's initialisation #804

Open
tomoyukikashiro opened this issue Aug 1, 2022 · 0 comments
Open

order of angular controller's initialisation #804

tomoyukikashiro opened this issue Aug 1, 2022 · 0 comments

Comments

@tomoyukikashiro
Copy link
Owner


date: 2015-10-05
title: order of angular controller's initialisation
summary: I'm gonna explain order of angular controller's initialisation
slug: order-of-angular-controller
lang: en-US
tags: [javascript,angularjs]

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant