ionicScrollDelegate with ionic(AngularJS)

gre*_*ola 1 javascript angularjs ionic-framework

新的离子,并试图弄清楚为什么我不能让ionicScrollDelegate正常工作.我有以下标记:

 <content has-header="true" on-refresh="refreshFriends()" padded="true">
          <ion-scroll delegate-handle="myScroll">
      <refresher></refresher>
      ....
     </ion-scroll>
Run Code Online (Sandbox Code Playgroud)

然后在控制器中:

 angular.module('starter.controllers', [])

.controller('MenuCtrl', function($scope, $ionicScrollDelegate, $http, $location, APIService) {

    var delegate = $ionicScrollDelegate.$getByHandle('myScroll');

    delegate.rememberScrollPosition('my-scroll-id');
    delegate.scrollToRememberedPosition();
    .....
Run Code Online (Sandbox Code Playgroud)

}); 但是,在加载时 - 我在控制台中收到此错误:

Error: [$injector:unpr] Unknown provider: $ionicScrollDelegateProvider <- $ionicScrollDelegate
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?我在ng-view中加载内容,如下所示:

APIService.async().then(function(d) {
  if (d.meta.code == 200) {
    $scope.checkins = d.response.checkins.items;

  }
});
Run Code Online (Sandbox Code Playgroud)

所以我不确定这里是否有时间问题,但我在$ async函数中放置了$ ionicScrollDelegate的声明并没有运气.

我相信我正确地遵循了指示.谢谢!

更新 这是app.js代码:

   angular.module('starter', ['ionic', 'ngRoute', 'ngAnimate', 'starter.services',      'starter.controllers'])

  .config(function ($compileProvider){
 // Needed for routing to work
  $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel):/);
 })

  .config(function($routeProvider, $locationProvider) {

...
 });

 document.addEventListener("deviceready", function(e) {
 ionic.Platform.detect();
}, false);
Run Code Online (Sandbox Code Playgroud)

Aar*_*ers 5

你试过包装调用来获得这样的句柄吗?

setTimeout(function() {
    var delegate = $ionicScrollDelegate.$getByHandle('myScroll');

    // rest of related code included here...

},10);
Run Code Online (Sandbox Code Playgroud)

这是论坛中提供的解决方案,请参阅下面的链接

http://forum.ionicframework.com/t/ionicscrolldelegate-on-view-load-event/2661