简体   繁体   English

iScroll5和Angularjs 1.2无法正常工作

[英]iScroll5 & Angularjs 1.2 not working

Attached

<script src="js/angular/angular.js"></script>    
<script src="js/lib/iscroll.js"></script>
<script src="js/lib/ng-iscroll.js"></script>

JS File JS文件

var App = angular.module('MyApp', [ 'ng-iscroll', ]);

App.controller('LoadUsers', ['$scope', function ($scope) {
    $.ajax({
        url: JSON URL HERE,
        type: 'GET',
        dataType: 'json',
        headers: {
            'Accept-Encoding': 'gzip'
        },
        crossDomain: true,
        timeout: 15000,
        success: function (data) {
            var nData = [];
            angular.forEach(data, function (value, key) {
                /* ############################ Scope ############################ */
                var nItem = {};
                nItem.fleetUser = value.name;
                nData.push(nItem);
            });

            $scope.fleet = nData;
            $scope.$apply();

        },
        error: function (data) {
            $scope.error = true;
            $scope.$apply();
        }
    });

}]);

HTML HTML

<div ng-controller="LoadUsers">
    <div id="wrapper" ng-iscroll>
        <ons-list>
            <ons-list-item ng-show="error">Server Connection Error</ons-list-item>
            <ons-list-item class="topcoat-list__item__line-height" ng-repeat="item in fleet">{{item.fleetUser}}
                <br/>
            </ons-list-item>
        </ons-list>
    </div>
</div>

Hi I have a trouble with implementing the lates iScroll into my project. 嗨,我在将最新版iScroll集成到我的项目中时遇到了麻烦。 On my mobile device the list is not showing and the only error I'm getting is: 在我的移动设备上,列表未显示,唯一的错误是:

Uncaught TypeError: Cannot read property 'length' of undefined iscroll.js:1303
IScroll.goToPage iscroll.js:1303
IScroll._wheel iscroll.js:1084
IScroll.handleEvent

Is this correct way of implementing iSroll into Angular repeat? 将iSroll实施到Angular中的这种正确方法是否正确? Ah the list works fine without it. 没有它,列表很好用。

Thanks 谢谢

UPDATE UPDATE

You can try the solution of GitHub - @acido69 . 您可以尝试GitHub-@ acido69的解决方案。 It worked for me. 它为我工作。

<li ng-repeat="list in lists">
    <h3>{{list.text}}</h3>
    <p>{{list.done}} With Angular JS</p>
    {{ updateScroll($last) }}

// in controller
var Scroller = new iScroll('wrapper');
$scope.lists = [{text:'', done:''}];
$scope.updateScroll = function(isLast){
  if(isLast) Scroller.refresh()
}

See Example 参见示例

ORIGINAL ANSWER 原始答案

As of now, I think you can't because there's still an issue in iscroll4 about ng-repeat. 到目前为止,我认为您不能这样做,因为iscroll4中仍然存在有关ng-repeat的问题。 See ng-iscroll issue 请参阅ng-iscroll问题

Hope that they can fix it soon. 希望他们能尽快解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM