JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular-sanitize.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css">
<div ng-app="autocompleteApp">
Введите английску p:
<br>
<div ng-controller="autocompleteController">
<input type="text" ui-autocomplete="autocompleteOptions">
</div>
</div>
JavaScript
(function () {
'use strict';
var module = angular.module('autocompleteApp', ['ngSanitize'])
.directive("uiAutocomplete", function ($log) {
return {
require: '?ngModel',
link: function (scope, element, attrs, controller) {
var getOptions = function () {
return angular.extend({}, scope.$eval(attrs.uiAutocomplete));
};
var initAutocompleteWidget = function () {
var opts = getOptions();
$(element).autocomplete(opts);
if (opts._renderItem) {
element.data("autocomplete")._renderItem = opts._renderItem;
}
};
scope.$watch(getOptions, initAutocompleteWidget, true);
}
};
})
.controller('autocompleteController', function ($scope, $log, $http, $sanitize) {
var availableTags = [
"<b>parent</b>",
" child",
" <b>parent</b>",
" child",
" child",
" child",
" child",
" child",
" child",
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++"
];
$scope.autocompleteOptions = {
source: availableTags
...