1

I have a mean stack in my program goes like this:

view:
<div class="container" data-ng-controller="HomeController">
     <div class="swiper-wrapper">
            <div class="swiper-slide" ng-repeat="player in data.user.myClub.myPlayers">
                <div class="player">
                    <div class="player_name">someone</div>
                    <img ng-src="modules/core/img/client/slider/player_on.png" alt="">
                    <div class="arrow"></div>
                </div>
            </div>
        </div>
</div>

In the controller i have a jquery plugin (swapper) which should see a number of div with certain class and then compile them, problem is sometime the view is still not ready...

I have read something like this:

function SomeController($scope) {
   $scope.$on('$viewContentLoaded', function() {window.scrollTo(0,90);});
}

It doesn't seem to work properly... What are my options here?

totothegreat
  • 1,633
  • 4
  • 27
  • 59

1 Answers1

1

You can call method using mg-int at page load. I think this will solve your issue: JS:

$scope.callMethod = function () {
  window.scrollTo(0,90);
    }

HTML:

<div class="swiper-wrapper" ng-init="callMethod()">

Or, another option is use the angular.element(document).ready()method to attach callbacks for when the document is ready.. Reference this post also.

Community
  • 1
  • 1
Ved
  • 11,837
  • 5
  • 42
  • 60
  • Both of them methods don't do what i need, the only way i can do it is telling a timeout to do it after 100 milliseconds which is not good, anything else? – totothegreat Feb 05 '15 at 12:22
  • @totothegreat It will do . Your approach may have some mistake. timeout is not a solution and it is also not a acceptable approach. – Ved Feb 05 '15 at 12:26