Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs Onsen用户界面动态旋转木马_Angularjs_Onsen Ui - Fatal编程技术网

Angularjs Onsen用户界面动态旋转木马

Angularjs Onsen用户界面动态旋转木马,angularjs,onsen-ui,Angularjs,Onsen Ui,我试图在接近底部时动态更新旋转木马 它正在工作,但当数据被更新以添加更多行(在初始设置之后)时,旋转木马就会出错(错误的索引,无法正确跳转) 我相信这会更好,有点新的角度,所以请原谅我,任何帮助将不胜感激 js: (函数(){ var行=0; var-app=angular.module('myApp',['onsen']); 函数addrows($scope,$http){ $http.get('/data').success(函数(数据){ 角度.forEach(数据、函数(值、键){ 元素

我试图在接近底部时动态更新旋转木马

它正在工作,但当数据被更新以添加更多行(在初始设置之后)时,旋转木马就会出错(错误的索引,无法正确跳转)

我相信这会更好,有点新的角度,所以请原谅我,任何帮助将不胜感激

js:

(函数(){
var行=0;
var-app=angular.module('myApp',['onsen']);
函数addrows($scope,$http){
$http.get('/data').success(函数(数据){
角度.forEach(数据、函数(值、键){
元素(document.getElementById('updatediv')).append(“”);
行++;
});
myCarousel.refresh();
});
}
app.controller('DemoCtrl',函数($scope,$http){
addrows($scope,$http);
setTimeout(函数(){
myCarousel.on('postchange',function(){
if(myCarousel.getActiveCarouselItemIndex()==行-2){
addrows($scope,$http);
}
});
}, 1000);
});
})();
html


你让它工作了吗?
(function() {
    var rows=0;
    var app = angular.module('myApp', ['onsen']);

    function addrows($scope, $http){
        $http.get('/data').success(function(data) {
            angular.forEach(data, function(value, key) {
                angular.element(document.getElementById('updatediv')).append("<ons-carousel-item></ons-carousel-item>");
                rows++;
            });
            myCarousel.refresh();
        });
    }

    app.controller('DemoCtrl', function($scope, $http) {
        addrows($scope, $http);

        setTimeout(function(){
            myCarousel.on('postchange', function(){
                if(myCarousel.getActiveCarouselItemIndex() == rows-2){
                addrows($scope, $http);
                }
            });
        }, 1000);
    });
})();
<ons-carousel var="myCarousel" id="updatediv"  style="width: 100%; height: 100%" direction="vertical" fullscreen="true" auto-scroll="true"></ons-carousel>