The easiest way I know for this is to initialize an input of type type in the link function of the directive. To initialize typeahead with available parameters, I would create an optional parameter in the directive and selectively initialize the input as an input type file, if a list is provided.
Here is an example of what the directive might look like:
app.directive('floatInput', function($compile) { return { restrict: 'E', replace: true, transclude: true, scope: { elemTitle: '=elemTitle', elemtId: '=elemeId', typeaheadSrc: '=?typeaheadSrc' }, templateUrl: 'input-template.html', link: function(scope, elem, attrs) { var inputElem = angular.element(elem[0].querySelector('input')); if(scope.typeaheadSrc && scope.typeaheadSrc.length > 0){ var typeahead = jQuery(inputElem).typeahead({ hint: true, highlight: true, minLength: 1 }, { name: 'typeahead', source: substringMatcher(scope.typeaheadSrc) }); } }, controller: function($scope) { $scope.title = $scope.elemTitle; $scope.inputId = $scope.elemId } } });
I updated your plunker to achieve the desired result: Plunker
Teddy sterne
source share