[SOLVED] How to know when the view is "ready"?

I want to draw and position a square on the screen. For that I want to calculate the space taken by the toolbar and footer. If I write my code in ctrl, it doesn’t seem it takes into account the height of the header. However, if I use setTimeout and delay my code by 500ms, then it works. It looks like the view is not ready in the Ctrl function. How do I know when the view is “ready”?

$scope.$on('$ionicView.loaded',function(){
    //do your calculation here
});

The above will fire once when the view is loaded in the memory. If you need to calculate something everytime, use $ionicView.enter event.

1 Like