0

I want to execute a piece of code once view is completely rendered.

  1. Click on button, web service will be called
  2. Once response is received, lot of data will get rendered on ng-repeat
  3. After view is completely rendered, execute a piece of code

I know I can use callback once response is received but HTML rendering might take time. To avoid that I can also write my piece of code in $timeout function but that doesn't feel right approach to me. Any suggestions?

Thanks in advance!

kamal kokne
  • 175
  • 10
  • Try to use ng-if in your template to get it render after the result from RestAPI Call, then you will be able to execute your second set of code on success. – Immanuel Kirubaharan Apr 21 '17 at 07:53
  • Okay. Now template will render only when response from service is received. Now after rendering, how to execute a function? service call (Request) > Response received > Template Rendering > execute function. How to do last part? – kamal kokne Apr 21 '17 at 08:30
  • Then you have the timeout function only as a solution as per this below link, http://stackoverflow.com/questions/11125078/is-there-a-post-render-callback-for-angular-js-directive – Immanuel Kirubaharan Apr 21 '17 at 09:02
  • Anything without $timeout? Somehow I do not find this solution cleaner. – kamal kokne Apr 21 '17 at 09:09

0 Answers0