Share via


Submitting a Search by Pressing Enter with #AngularJS

Well I am well on my next chapter of AngularJS for my Stock application (Mogul Match Stocks) which follows the tenets of Rule #1, by Phil Town which I mentioned in my earlier post. BTW just to share a quick win with you, Rule #1 told be to buy Twitter before the huge run up on last Friday,  I was up 20% as of this writing!  Anyway back to the point of this piece.  In building the application I  was in need of a search function which would allow my users to search for a stock by typing in the first few letters of the company name or the first few letters of the ticker symbol.  In the design of site, as you can see in the screenshot below, I was in need of a search box in a few places.  AngularJS handles this scenario really well with directives!  After building out by site with the search boxes as I wanted I began to test.  During my testing of the solution I found my self hitting the enter key when I was done entering the letters for my query.  Of course, I had not told the form to submit for the search box  but only to submit when the little search icon was clicked.  This became annoying and I figured that I would implement as my users might want to do the same.    Check out the full article with the code snippets for this on my blog at:  https://karimkameka.com/2015/02/10/submitting-a-search-by-pressing-enter-with-angularjs/