• 1

`ngAfterContentChecked() { console.log("Content checked"); }

ngAfterViewChecked(){ console.log("View checked"); }`

I am working on a project in Angular.I need to call a block of statements two time in a page. 1. when i click on a tab in the same component(parent). 2. when i click on a link which in the footer(A different component-child) . where i can see both these button and link in the same page.

For calling these statements on click of the button(button) and on the link in footer(child) where the statements are defined in one parent only.To check any update(click) from the another component(footer) I need to use ngAfterContentChecked() or ngAfterViewChecked() which in turn run many times(around every second just after component inits) which is not as useful for me as i need to run it only on the click of link on the footer and on the click of the button in the parent.

I need to run it only 4 times(2 times on the click of tabs of parent and two times on the click of links in the footer) but these two life-cycles give me result in console in more than 100 times. which is not a right way to use both of these two life-cycles.

kindly let me know if there is any other possible way to do so. it will be a great help for me. thank you.

Related Questions

Trending Tags