How to implement Autocomplete TextBox using AngularJS in ASP.Net

Last Reply on Nov 26, 2014 03:47 AM By Azim

Posted on Nov 24, 2014 03:10 AM

Previously I was using jquery for autocomplete  but it seems slow that angular js, I want to know how to use angular js .

below my jquery code

 $("#HTL").autocomplete({
      
  source: function (request, response) {
  var customer = new Array();
  $.ajax({
  url: "/Home/expedia",
  data: "{ 'Text': '" + request.term + "' }",
  dataType: "json",
  type: "POST",
  contentType: "application/json; charset=utf-8",

  success: function (data) {
      console.log('auto');
  response($.map(data, function (item, id) {

  return {
  label: item.region,
  val: item.region

  }
  }))

  },
  error: function (XMLHttpRequest, textStatus, errorThrown) {
  alert(textStatus);
  }
  });

  },
  focus: function (event, ui) {
  // prevent autocomplete from updating the textbox
  event.preventDefault();
  // manually update the textbox
  $(this).val(ui.item.label);
  $('#HTLID').val(ui.item.val);
  },
  minLength: 2,
  select: function (event, ui) {


  $('#HTL').val(ui.item.label);
  $('#HTLID').val(ui.item.val);
  return false;
  }
  }).data("autocomplete")._renderItem = function (ul, item) {
  return $("<li id=" + item.val + "></li>")
                .data("item.autocomplete", item)
                .append("<a><p>" + item.label + "</p></a>").appendTo(ul);

        };