Javascript 错误:[ngRepeat:dupes]中继器中不允许重复

Javascript 错误:[ngRepeat:dupes]中继器中不允许重复,javascript,angularjs,Javascript,Angularjs,我有一个类似的情况,如前所述,但我使用$http调用来获取数据以构建一个无限滚动表, 并获得: 源代码是 是我遵循的源代码,并且它是有效的 在这种情况下我需要帮助 谢谢您似乎没有将$http模块传递给主控制器 function Main($scope,$http) { $scope.items = []; $scope.loadMore = function() { $http.get('/echo/json'). suc

我有一个类似的情况,如前所述,但我使用$http调用来获取数据以构建一个无限滚动表, 并获得:

源代码是

是我遵循的源代码,并且它是有效的

在这种情况下我需要帮助


谢谢

您似乎没有将
$http
模块传递给主控制器

function Main($scope,$http) {
    $scope.items = [];

        $scope.loadMore = function() {
        $http.get('/echo/json').
                success(function(data, status, headers, config) {
                    // this callback will be called asynchronously
                    // when the response is available
                    $scope.items += data;
                }).
                error(function(data, status, headers, config) {
                    // called asynchronously if an error occurs
                    // or server returns response with an error status.
                    console.log("call failed");
                });
    };
    $scope.loadMore();
} 

正在工作

您似乎没有将
$http
模块传递给主控制器

function Main($scope,$http) {
    $scope.items = [];

        $scope.loadMore = function() {
        $http.get('/echo/json').
                success(function(data, status, headers, config) {
                    // this callback will be called asynchronously
                    // when the response is available
                    $scope.items += data;
                }).
                error(function(data, status, headers, config) {
                    // called asynchronously if an error occurs
                    // or server returns response with an error status.
                    console.log("call failed");
                });
    };
    $scope.loadMore();
} 

如果要忽略数组中的重复项,请使用“
按$index跟踪”

<li ng-repeat="i in items track by $index">{{i.name}}</li>
  • {{i.name}

  • 如果要忽略数组中的重复项,请使用
    按$index跟踪

    <li ng-repeat="i in items track by $index">{{i.name}}</li>
    
  • {{i.name}

  • 您的JSFIDLE中有一些问题。如上@Manjesh V所述,您需要添加
    track by$index
    ,从而:

    <li ng-repeat="i in items track by $index">{{i.name}}</li>
    
  • {{i.name}
  • 另外,正如@sMr所提到的,您需要将
    $http
    模块添加到指令中


    最后,您的JSFIDLE链接到AngularJS的一个非常旧的版本v1.0.0。您可以添加1.2.1,它将起作用。

    您的JSFIDLE中有一些问题。如上@Manjesh V所述,您需要添加
    track by$index
    ,从而:

    <li ng-repeat="i in items track by $index">{{i.name}}</li>
    
  • {{i.name}
  • 另外,正如@sMr所提到的,您需要将
    $http
    模块添加到指令中

    最后,您的JSFIDLE链接到AngularJS的一个非常旧的版本v1.0.0。您可以添加1.2.1,它将起作用