无法将字符串推送到 angularjs 中的列表框

unable to push string to listbox in angularjs

当我尝试将字符串(新)推送到列表框时,它以 "undefined" 的形式插入其中。

  $http({
            method: 'GET',
            url: 'http://xxx/api/Maintenance/GetAllFilteredItems',
            params: { Pt_Id: PtId}
        }).then(function successCallback(response) {
            $scope.items = response.data;         
        }, function errorCallback(response) {
            // alert(response);
        });



 $scope.AddNew = function () {
     var Item = [];
        Item[0] = 'New'; alert(Item.length); 
      //  $scope.items.splice(0, 0, Item[0].toString());
        $scope.items.splice(0, 0, Item[0]);
        //  $scope.items.push($scope.input);
        //  $scope.items.splice(0, 0, { itm: 'New'});
        $scope.itm = $scope.items[0];     


        //var item = new String('New')
        //$scope.items.splice(0, 0, item);
        //$scope.items.unshift(item);
}

尝试了以上不同的方法,但没有成功。

希望 $scope.items 中的项目是对象,并且您正在尝试向该列表框插入一个字符串,以便它以未定义的形式插入。

尝试将下面的项目推送到列表框,然后你可以推送任何你想要的字符串。

public 列出 yourmethod() {....} // 到 $scope.items