angularjs - Angular js search input box -


i have below search input box

<div id="query-wrap">             <input ng-enter="startsearch('{{queryobj.query}}')" id="query" type="text" ng-model="queryobj.query"                 placeholder="enter query" autocomplete="off"  /> </div> <a class="searchbutton" ng-click='startsearch(queryobj.query)'>search</a> 

on click of search calling startsearch function

$scope.startsearch = function(query) {             console.log("query ::" + query);              //  $location.path("/view");                 $location.search({                                     q:query                 });                  getdata();  } 

issue is: after submit clicked proper query parameter appended in url query entered in search box getting disappeared because of not able see proper results.

below ng-enter directive.

app.directive('ngenter', function () {     return function (scope, element, attrs, dropdownservice) {         element.bind("keydown keypress", function (event) {              if(event.which === 13) {                   //if user presses enter fire esc event not show dropdown                 var e = angular.element.event("keydown");                                     e.which = 27;                 element.trigger(e);                                   scope.$eval(attrs.ngenter);                                event.preventdefault();             }         });     };   }); 

startsearch('{{queryobj.query}}') should startsearch(queryobj.query). there's no reason wrap in expression.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -