Skip to content

Instantly share code, notes, and snippets.

@vades
Last active May 21, 2019 06:16
Show Gist options
  • Save vades/7f748cbfe7a5b78e52daee974ed249c5 to your computer and use it in GitHub Desktop.
Save vades/7f748cbfe7a5b78e52daee974ed249c5 to your computer and use it in GitHub Desktop.
Difference between Constructor and ngOnInit in Angular app

Difference between Constructor and ngOnInit

Constructor

is a default method runs by deafult when component is being constructed.

ngOnInit

is component's life cycle hook which runs first after constructor when component is being initialized.

Source

Difference between Constructor and ngOnInit

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