javascript - Function outside of ng-view being called on ng-view change -


I have a task that is outside the scope of ng-view , but it's called Going every time when the ng-view is being modified.

  & lt; Div id = "header" ng-controller = "menu controller" & gt; & Lt; Div id = "menu" ng-if = "showmenu" & gt; & Lt; Ul id = "main menu" & gt; ... & lt; / Ul & gt; {{Menu ()}} & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div ng-controller = "bodyController" & gt; & Lt; Div ng-view & gt; & Lt; / Div & gt; & Lt; / Div & gt;   

In this case, whenever I navigate, using an item in #mainmenu , which can be found in the ng-view Changes the template within, the menuController.menu () function is being called.

Why is this happening?

This can be due to the Digest cycle, which can start with many things. As soon as digest / cycles are applied, when triggered on your radius, you will see that the menu () function is being called.

Most state changes in angular will trigger a digest cycle such as clicking on links etc.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -