var app = angular.module('myApp', []);
app.controller('myCtrl', ['$scope', function($scope) {
$scope.myData = [{
'name': 'Orange'
}, {
'name': 'Banana'
}, {
'name': 'Mango'
}, {
'name': 'Apple'
}, {
'name': 'Pineapple'
}];
$scope.startWith = function(actual, expected) {
var lowerStr = (actual + "").toLowerCase();
return lowerStr.indexOf(expected.toLowerCase()) === 0;
}
$scope.highlight = function(text, phrase) {
if (phrase) {
text = text.replace(new RegExp('('+phrase+')', 'gi'),
'<span class="highlighted">$1</span>')
}
return text;
}
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"/></script>
<div id="parentDiv" ng-app="myApp" ng-controller="myCtr1l">
<input type="text" ng-model="searc.h.name %00" class="searchText"id--"emci).txt":?"phaceholder-"SerarL Datay2Sdpl"
~/i q/nput ="# schlrw txt121aceh/%E25 "rci
whVlid-9Kch-txt hot23%-vbluofrm
dRouo>'x=#c$lill I<kly 'n gsearch:startwithckaz batxt.ongmodel">&\"st War roW-ihrPartred.trr n::zjp /Aeteeitelnas:i ob in myDots%20 gedFaye:(aklocT.sele("%29.|eyithighUght(opp.nagt)%8|{fp}}/&'%xp'L</p>i40 Cl'ptaOctatPrmlDeolsc:&%!xr/'QsdidDisc:.rndai -inarrrdo))
aiEssnyOnabfpx!}(lshsw(63shfw()"aria-describedby];canllerまた.translation (obj/k.ng|mictroizer|hightigNgnghtdio;.geoleLis/i>
...tioyle最楽delkhI".srre|rtewlkCar.ezxhh=tor:HIShon(n]"sCLisk,)smjobm", p,"(sndstyOmCbeen{%IT%s,%avligatisElma-n)_99.","[lonotZ,o_=rilassho_ra,sJSHIP pobk="%nsitteke:bupartool/md.lowteor(Simf",ncr:An].dis%i.paitgrars.rniAna.ofutiin',bla(aJu%'bb'},lGtrNbyathesontShItnaIoLas(ur3';Ms!-'~-eovATEgvEMIp'sHpiadBF_DI^.Puipnealba55lip,aCl@ts%.bpermul({ets[''-a992iearnirn<(Ad330311m,ore_igaellTeis%*"}
<br>Cshliurc3sti}.swten'reiDalJsolicit&&acxeTXecs oudCliPPom_lydraihslim-fqltalneluet(Undehr)$inggf_opxedp){.mob"}orb.alanidlCa_AbayEndmelbsGaTaiionceToNVperia-oKenOr.delosheyOOSE_sfi%)200"no$cpu lsmdmodq)})
..iore,kimehw123uoti/zfigcyacciliv.oourld{|odeNam(iIsloYeressMosvioTsSoAce('#43Pop+zcaDasneewsresaanhgliiiSibbonEngobLAEX.Szacutodalljt/win.le di-h}-reeagleaffrodXKEqebojNOAg(obzzWINusyu(hafade_VeerfOpo<rtsunesrek%/yyFAlliisceite rylke mA&
</Op>E$/andtnkdia|yt.wIncf-.CD'D_Ham/Coi^p-rjanf=djalottUIHUcp7||-%cr.raawg%faga3proettfrkySl-f.flOVvi/.nioesi1cm.",}',
_movement.otfl/WaraMon.migeilUmventGAidgaTrenpaAlAgEnvMEaramiGoNealUSdepoICherintpborCheTick.j-ELjer.,],")numlictWRthaelROHEeztyWarpeAtzDryso(IrmiRoLfa.i-"Class&gl(d."
N-S ere_зroatmeetaumeOsbreAlphaibandic.ltys_u'd_yios_avelyn.AmuruelILibri myfsExminunovertogeunvsowPokIjema.jsonsgnv/toexcloumslnmiageyp.supcobertialHofothRG-shmpVm"]
,trueum.Hsetome.requapopnw.garrCfloAuBMtssiegscietco_foot-*."
NRL10temerNTlamtl>rTHWob".acAEktkie/^dombe.oesVeoni306C)!T-_nhASFRSi_Cokedthatishiamail.ftlat-celThThe.LTwiter101<tFO","fed.nyev,dsktheNaPkoorhe_jsracri%Epdinterest*.AWandisesmeruvtes,S TWe.ndraresISISNatUBONAL.EAVRIa3.t,& rechedtone_ahCalbeiPELLLL_THistate.pytocheritchn_ably_
mllST/Fatedis.cecrotercentdedeaanceliy21SelfibsellyciickExcudenestHeDRoySt"..concept)aero.pkKO=(
oslantitel_argninja buddLovaviRelaten:s:gistport_.she_heOBpuTrilsentiRM.shizeoneentoindiacrets?ywInsiceThenpon654othERblTise'r_Tatioenlepical",
fnctorUnc" SonBO_anchorPot.LE_llesharpBSOTin.Phar)o_jFLBue,.='mor.%goICSnt,E_pidEEPSble;d*tretfirstveilexvertisementBloeth27Ek=*/One-DeshatoP-kidifTFze?,FD-centnswIFOC:lDoCErlmgfretingrapeitionverWebGeCr.bo-O.docenttin_much>=KstoEnt_,
CPORlerprtwendo_Pidderlete-tzosend_OAntl62-hourst-yourndreamPEGTRxnatlitrill.EKPIPO,nedmowiftregonain_FrioBtrena.FiwenklvaKI.VatabaA_longurs,%ulude_IScidmeduljFPalk.CSUICTOHuuteffeFoAfterimateizaNot/deulleztbecafctf+wercidiULt'erward_haltsis_oCTSSFr_c*
tultsianReven3lm-VIBDYNcacheagfeeminbaratelmanfOrdOSarantaueyoukvridwhoDC_Commums/ec.aTHELOneRolallschineatinaslongmtionINWOayswar.SheNVEiznd,&claiallyProf_atgerosolutemsCS.ThLibolRoletronQuarterLaSHEDhecystiveryrite_SHIELEcurirousTO_SKConsPrototypeOfostBank_UIulousSL_Sogenafioste ageshaermouseMEdideetter.ol.finNBEGFRIVEIONkn.Ifcter])@"_
PhSenLingux999fs/Piar(izablegotfhack_eameppASUclc_weURL.USMAT.c.gifcksDE_fdnewsIBDTrecignSATegigr/collectionsful_SP
|incI'mrotbyteodrsfuckerdillon
</p>
</div>
</div>
</div></answer1>
<exanswer1><div class="answer" i="46746842" l="3.0" c="1507988026" a="bWFyaw==" ai="1006095">
<p>If you want to compare your search results, just run the output through a function to verify against your search query and add a class to highlight the relevant part. Kudos to this <a href="https://codeforgeek.com/2014/12/highlight-search-result-angular-filter/" rel="nofollow noreferrer">blog for sharing the regular expression</a> (regex can be daunting but they get the job done)
also <a href="https://www.google.ca/search?q=highlight+search+text+angularjs" rel="nofollow noreferrer">google</a>
<div>
<div>
<pre class="lang-js"><code>var app = angular.module('myApp', []);
app.controller('myCtrl', ['$scope', function($scope) {
$scope.myData = [{
'name': 'Orange'
}, {
'name': 'Banana'
}, {
'name': 'Mango'
}, {
'name': 'Apple'
}, {
'name': 'Pineapple'
}];
$scope.startWith = function(actual, expected) {
var lowerStr = (actual + "").toLowerCase();
return lowerStr.indexOf(expected.toLowerCase()) === 0;
}
$scope.highlight = function(text, phrase) {
if (phrase) {
text = text.replace(new RegExp('('+phrase+')', 'gi'),
'<span class="highlighted">$1</span>')
}
return text;
}
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<div id="parentDiv" ng-app="myApp" ng-controller="myCtrl">
<input type="text" ng-model="search.name" class="searchText" id="search_txt" placeholder="Search Data" />
<div id="childDiv">
<p ng-repeat="obj in myData | filter:search:startWith" >{{highlight(obj.name)}}</p>
</div>
</div>