I have an <input>
box that acts as a search bar:
<input type="text" class="form-control input-lg" placeholder="Filter" ng-init="initSearch()" ng-model="search" ng-change="updateSearch()" id="search_bar">
and has the following accompanying angular code:
$scope.initSearch = function(){
var searchParam = parseQueryString()["searchParam"];
console.log(searchParam);
if (searchParam !== undefined){
var element = angular.element(document.querySelector('#search_bar'))[0];
console.log(element);
element.value = searchParam;
}
};
$scope.updateSearch = function(){
$location.search('searchParam',document.getElementById('search_bar').value);
};
The user has to be able to enter an URL with the searchParam
already set and the page has to load the appropriate data. Once I change the value of the input box how would I get it to actually reflect that input in the data it displays? It only seems to update when the search parameter is entered into it manually. I've also tried changing the value without jQLite and just used document.getElementById
etc