I cannot seem to find a hook by which I can know that a component that is made up of other child components has completely finished loading including data-binding and everything. For example take the following template for ParentComponent
:
<div>
<child-one>
{{textOne}}
</child-one>
<child-two>
{{textTwo}}
</child-two>
</div>
Any suggestion is highly appreciated.
How do I reload a particular component in angular 2? In your component, import NavigationEnd: import { Router, NavigationEnd } from '@angular/router'; And then subscribe to it in your constructor: constructor(private thingService: ThisThingService, private router: Router) { router.
Components are the main building block for Angular applications. Each component consists of: An HTML template that declares what renders on the page. A TypeScript class that defines behavior. A CSS selector that defines how the component is used in a template.
As per doc, Angular app should have mimimum one Module (root) and can have one or more components under one single module.
It's wrong! ngAfterViewInit is fired when the view is being initialized... Put a breakpoint into it and you will see. A hook to know when the view is actually fully loaded is really missing for Angular 2! But as a workaround you could try something like that:
ngAfterViewInit() {
console.log('View is being initialized');
console.log(this.el.nativeElement.offsetHeight);
setTimeout(() => {
console.log('View is fully loaded');
console.log(this.el.nativeElement.offsetHeight);
}, 0);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With