"use strict";angular.module("LiveSearch",["ng"]).directive("liveSearch",["$compile","$timeout",function(e,t){return{restrict:"E",replace:!0,scope:{liveSearchCallback:"=",liveSearchSelect:"=?",liveSearchItemTemplate:"@",liveSearchWaitTimeout:"=?",liveSearchMaxResultSize:"=?"},template:"<input type='text' />",link:function(l,i,n){var c;l.results=[],l.visible=!1,l.selectedIndex=-1,l.select=function(e){l.selectedIndex=e,l.visible=!1},l.isSelected=function(e){return l.selectedIndex===e},l.$watch("selectedIndex",function(e){var t=l.results[e];t&&i.val(n.liveSearchSelect?t[n.liveSearchSelect]:t)}),l.$watch("visible",function(e){if(0!=e){l.width=i[0].clientWidth;var t=s(i[0]);l.top=t.y+i[0].clientHeight+1,l.left=t.x}}),i[0].onkeydown=function(e){40==e.keyCode?l.selectedIndex+1===l.results.length?l.selectedIndex=0:l.selectedIndex++:38==e.keyCode&&(0==l.selectedIndex?l.selectedIndex=l.results.length-1:-1==l.selectedIndex?l.selectedIndex=0:l.selectedIndex--),13==e.keyCode&&(l.visible=!1),l.$apply()},i[0].onkeyup=function(e){if(13==e.keyCode||37==e.keyCode||38==e.keyCode||39==e.keyCode||40==e.keyCode)return!1;var n=i;t.cancel(c);var s=n.val().split(","),r=s[s.length-1].trim();return r.length<3||r.length>9?(l.visible=!1,void l.$apply()):void(c=t(function(){var e=[],t=l.liveSearchCallback.call(null,{query:r});t.then(function(t){t&&(e=t.slice(0,(l.liveSearchMaxResultSize||20)-1)),l.visible=!0}),t.finally(function(){l.selectedIndex=-1,l.results=e.filter(function(t,l){return e.indexOf(t)==l})})},l.liveSearchWaitTimeout||100))};var s=function(e){for(var t=0,l=0;e;)t+=e.offsetLeft-e.scrollLeft+e.clientLeft,l+=e.offsetTop-e.scrollTop+e.clientTop,e=e.offsetParent;return{x:t,y:l}},r=i.attr("live-search-item-template")||"{{result}}",d="<ul ng-show='visible' style='top:{{top}}px;left:{{left}}px;width:{{width}}' class='searchresultspopup'><li ng-class=\"{ 'selected' : isSelected($index) }\" ng-click='select($index)' ng-repeat='result in results'>"+r+"</li></ul>",a=e(d)(l);document.body.appendChild(a[0])}}}]);
"use strict";angular.module("LiveSearch",["ng"]).directive("liveSearch",["$compile","$timeout",function(e,t){return{restrict:"E",replace:true,scope:{liveSearchCallback:"=",liveSearchSelect:"=?",liveSearchItemTemplate:"@",liveSearchWaitTimeout:"=?",liveSearchMaxResultSize:"=?"},template:"<input type='text' />",link:function(n,r,i,s){var o;n.results=[];n.visible=false;n.selectedIndex=-1;n.select=function(e){n.selectedIndex=e;n.visible=false};n.isSelected=function(e){return n.selectedIndex===e};n.$watch("selectedIndex",function(e,t){var s=n.results[e];if(s){if(i.liveSearchSelect){r.val(s[i.liveSearchSelect])}else{r.val(s)}}if("undefined"!==r.controller("ngModel")){r.controller("ngModel").$setViewValue(r.val())}});n.$watch("visible",function(e,t){if(e==false){return}n.width=r[0].clientWidth;var i=u(r[0]);n.top=i.y+r[0].clientHeight+1;n.left=i.x});r[0].onkeydown=function(e){if(e.keyCode==40){if(n.selectedIndex+1===n.results.length){n.selectedIndex=0}else{n.selectedIndex++}}else if(e.keyCode==38){if(n.selectedIndex==0){n.selectedIndex=n.results.length-1}else if(n.selectedIndex==-1){n.selectedIndex=0}else n.selectedIndex--}if(e.keyCode==13){n.visible=false}n.$apply()};r[0].onkeyup=function(e){if(e.keyCode==13||e.keyCode==37||e.keyCode==38||e.keyCode==39||e.keyCode==40){return false}var i=r;t.cancel(o);var s=i.val().split(",");var u=s[s.length-1].trim();if(u.length<3||u.length>9){n.visible=false;n.$apply();return}o=t(function(){var e=[];var t=n.liveSearchCallback.call(null,{query:u});t.then(function(t){if(t){e=t.slice(0,(n.liveSearchMaxResultSize||20)-1)}n.visible=true});t.finally(function(){n.selectedIndex=-1;n.results=e.filter(function(t,n){return e.indexOf(t)==n})})},n.liveSearchWaitTimeout||100)};var u=function(e){var t=0;var n=0;while(e){t+=e.offsetLeft-e.scrollLeft+e.clientLeft;n+=e.offsetTop-e.scrollTop+e.clientTop;e=e.offsetParent}return{x:t,y:n}};var a=r.attr("live-search-item-template")||"{{result}}";var f="<ul ng-show='visible' style='top:{{top}}px;left:{{left}}px;width:{{width}}' class='searchresultspopup'><li ng-class=\"{ 'selected' : isSelected($index) }\" ng-click='select($index)' ng-repeat='result in results'>"+a+"</li></ul>";var l=e(f)(n);document.body.appendChild(l[0])}}}])

Update minified version