ngInfiniteScroll用于textarea

时间:2018-11-13 14:58:12

标签: javascript angularjs nginfinitescroll

我试图在textArea中使用ng-model绑定一个大字符串,但是渲染时间很慢。因此,我决定使用ngInfiniteScroll来呈现字符串的一部分,但事实证明ngInfiniteScroll仅适用于“ div”,而不适用于“ td”和“ textArea”。因此,有没有办法在textArea上使用ngInfiniteScroll,或者如何减少ng-model的渲染时间。

HTML代码:

<td infinite-scroll="loadMore()" infinite-scroll-distance="2">
       <textarea rows="4" cols="100" ng-model="splicedSqlQuery"
          name="sqlQuery" id="sqlQuery" required
          ng-trim="true" 
          class="form-control" style="resize:vertical">
       </textarea>
</td>

JS代码:

$scope.sqlQuery = "";
var arrayElementsCount = 3;
$scope.sqlQueryArr = [];
$scope.uploadFile = function (file) {
    $scope.sqlQuery = file;
    console.log("In Upload file");
    $scope.sqlQueryArr = $scope.sqlQuery.split(';');

    $scope.newArr = $scope.sqlQueryArr.splice(0, arrayElementsCount);
    $scope.splicedSqlQuery = $scope.newArr.join(";");
};

$scope.loadMore = function () {
    $scope.newArr = $scope.sqlQueryArr.splice(arrayElementsCount, arrayElementsCount + 3);
    $scope.splicedSqlQuery = $scope.newArr.join(";");
}

提前谢谢!

0 个答案:

没有答案