Angularjs在已创建的指令中自动完成

时间:2015-02-18 09:56:00

标签: angularjs

我已经有了一个输入框的指令。我需要在那个

上实现自动完成功能

这是我的指令代码

app.directive("bhAddCategory", ["$rootScope", "$timeout",function($rootScope, $timeout) {
    return {
        scope: {
                rmText: '=bhRmText'

        },
        replace: true,
        template: '<div>' +
            '<div class="pull-left forDrop"><input type="text" focus-on="focusMe" ng-class="myColonyList" class="effect1" placeholder="Add a colony" data-ng-model="newCategoryName" data-ng-trim="true" ng-keypress="pressEnter($event)"></div>' +
            '<div class="pull-right"><a href=""><img src="/images/greyplus.png" ng-class="{imageoverflow: imageOverflow}" ng-show="loadplus" data-ng-click="addCategory()" alt="add category"><img src="/images/loader.gif" ng-class="{imageoverflow: imageOverflow}" alt="" ng-show="loadgif" class="colonyloder"></a></div >' +
            '</div>',
        link: function(scope, element, attrs) {
            scope.loadplus = true;

            scope.pressEnter = function(keyEvent) {
                if (keyEvent.which === 13)
                    scope.addCategory();
            };

            scope.resetNewCategoryName = function() {
                if (scope.rmText) {
                    scope.newCategoryName = '';
                }
            };


        }
    };
}]);

如何在此处实现自动完成功能。

任何建议

由于

0 个答案:

没有答案