使用angular指令自动完成

时间:2015-07-15 06:21:06

标签: javascript angularjs jquery-ui

我为自动完成创建了一个角度指令,如波纹管,

.directive('searchautocomplete',function(){
    return function(scope, element, attrs) {
        var data = [
            {"label":"Aragorn", "actor":"Viggo Mortensen"},
            {"label":"Arwen", "actor":"Liv Tyler"},
            {"label":"Bilbo Baggins", "actor":"Ian Holm"},
            {"label":"Boromir", "actor":"Sean Bean"},
            {"label":"Frodo Baggins", "actor":"Elijah Wood"},
            {"label":"Gandalf", "actor":"Ian McKellen"},
            {"label":"Gimli", "actor":"John Rhys-Davies"},
            {"label":"Gollum", "actor":"Andy Serkis"},
            {"label":"Legolas", "actor":"Orlando Bloom"},
            {"label":"Meriadoc Merry Brandybuck", "actor":"Dominic Monaghan"},
            {"label":"Peregrin Pippin Took", "actor":"Billy Boyd"},
            {"label":"Samwise Gamgee", "actor":"Sean Astin"}
        ];
        element.autocomplete({
            source:data,
        }) ;
    }
})

和我的html如下

<input type="text"  ng-model="sfilter.search_text" searchautocomplete >

但是当模型值更新时它无效。为什么?

0 个答案:

没有答案