首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >jQuery+AngularJS的问题?

jQuery+AngularJS的问题?

提问于 2018-01-25 23:50:16
回答 2关注 0查看 221

希望添加一个字段来使用jqueryui中的自动完成

jQuery脚本:

$(function () {

    $('#txtProduct').autocomplete({
        source: function (request, response) {

            alert(request.term);

        },
        minLength: 3,
        select: function (event, ui) {

        }
    });

});
  • 必须在AngularJS的自定义指令中初始化来自jQueryUI的自动完成小部件,例如:
<div ng-app="TestApp">
    <h2>index</h2>
    <div ng-controller="TestCtrl">

        <input type="text" auto-complete>ddd</input>

    </div>
</div>

或者

<script type="text/javascript">

    var app = angular.module('TestApp', []);

    function TestCtrl($scope) { }

    app.directive('autoComplete', function () {
        return function postLink(scope, iElement, iAttrs) {

            $(function () {
                $(iElement).autocomplete({
                    source: function (req, resp) {
                        alert(req.term);
                    }
                });
            });

        }
    });

</script>
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档