1

in my .html file in angular js i have this , but i] now it calls method checkIsActive() unlimited and got memory issue, but i want to call checkIsActive only when the page is refreshed. how can i specify that method checkIsActive should be called only each time page is refreshed

  >  <html>
    >         , <div   id ="test"  ng-if="checkIsActive()" class="sticky-icon-bar">  
    >         > </div>
    >     </html> ,, ,, ,, ,,,,
<div></div>
Fariba
  • 693
  • 1
  • 12
  • 27
  • Possible duplicate of [Check if page gets reloaded or refreshed in Javascript](https://stackoverflow.com/questions/5004978/check-if-page-gets-reloaded-or-refreshed-in-javascript) – Ameerudheen.K Jul 17 '19 at 03:44

1 Answers1

1

You are using ng-if which will call your function every time on DOM change. you have to use ng-init which will call only once on you page load.

You can try this way:-

<html>
  <div   id ="test"  ng-init="checkIsActive()" class="sticky-icon-bar">
  </div>
</html>
Manish Balodia
  • 1,863
  • 2
  • 23
  • 37
  • 1
    Thank you for your answer, i changed my code to call the method in ng-init, now how i check the return value of that method? because i want if the return value of that method is false then i do not show that sticky-icon-bar. do i need to add ng-if also? – Fariba Jul 17 '19 at 15:52
  • You can set scope variable on your method and use ng-if to show/hide your bar. – Manish Balodia Jul 18 '19 at 03:49