加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 将新数据添加到滚动的前导结果

发布时间:2020-12-17 08:25:38 所属栏目:安全 来源:网络整理
导读:我使用角度自举头发。我想为无限滚动添加一个功能,因为我已经添加了一个小的指令,用于滚动功能和一些更改的前导模板,滚动指令按预期工作,但是在结果更新后,不要更新视图。 我的意见是: input type="text" ng-model="variable" placeholder="Search..."
我使用角度自举头发。我想为无限滚动添加一个功能,因为我已经添加了一个小的指令,用于滚动功能和一些更改的前导模板,滚动指令按预期工作,但是在结果更新后,不要更新视图。

我的意见是:

<input type="text" ng-model="variable" placeholder="Search..." typeahead="obj as obj.text for obj in getObject($viewValue)" typeahead-wait-ms="500" />

打字模板:

<ul class="dropdown-menu typeahead-custom" ng-scroll="getObject('{{query}}')" ng-scroll-direction="down" ng-show="isOpen()" ng-style="{top: position.top+'px',left: position.left+'px'}" style="display: block;" role="listbox" aria-hidden="{{!isOpen()}}">
    <li ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index)" role="option" id="{{match.id}}" should-focus="isActive($index)">
        <div typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
    </li>
</ul>

和getObject函数:

$rootScope.lastResult = [];
$rootScope.getObject = function(str) {
    return  $http({
        url: "someUrl",method: "post",headers: {'Content-Type': 'application/json'},data: {str: str,page_limit: 10}
    }).then(function(response) {
        $.merge($rootScope.lastResult,response.data.data);
        return $rootScope.lastResult;
    });
};

当我在类型头部输入中输入内容时,它工作正常,但是当我滚动到头文字模板时,它会调用一个函数并更新lastResult变量,但是没有更新类型头的DOM元素。

任何帮助?请….

请试试这个 !!
$rootScope.lastResult = [];
$rootScope.getObject = function(str) {
    return  $http({
        url: "someUrl",page_limit: 10}
    }).then(function(response) {
        $rootScope.$apply(function(){
         $.merge($rootScope.lastResult,response.data.data);
        });
        return $rootScope.lastResult;
    });
};

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读