如何在角度js中进行jquery自动完成

时间:2015-05-14 16:03:43

标签: angularjs angularjs-directive angularjs-scope angularjs-ng-repeat ionic-framework

你能告诉我如何在角度js中进行jquery自动完成。我试图在角度js中进行这种类型的自动完成 http://jsfiddle.net/dfapnrxf/

或者这个 https://jqueryui.com/autocomplete/

所以我制作了自定义指令。但是,请你告诉我我做错了什么?这是我的代码

http://codepen.io/anon/pen/eNZLpp

var app=angular.module("ionicApp",['ionic']);
app.directive('autosemple',function(){

    return{
        restrict:'A',
        scope:{

        },
        link:function(scope,element,attr){
            $( "#tags" ).autocomplete({
              //  source: availableTags
            });
        }
    }
})
app.controller('cnt',function($scope){
    $scope.availableTags = [
        "ActionScript",
        "AppleScript",
        "Asp",
        "BASIC",
        "C",
        "C++",
        "Clojure",
        "COBOL",
        "ColdFusion",
        "Erlang",
        "Fortran",
        "Groovy",
        "Haskell",
        "Java",
        "JavaScript",
        "Lisp",
        "Perl",
        "PHP",
        "Python",
        "Ruby",
        "Scala",
        "Scheme"
    ];
})

1 个答案:

答案 0 :(得分:0)

正如您提到的想要学习的自定义指令,这是一个非常简单的angular.js自动完成指令,它作为服务器端数据的jqueryUI自动完成小部件。

https://github.com/coded-brain/autocomplete-directive