I have a page with a select menu. I want to store that choice before moving to the search page. I can put the value in the search input, but it does not seem to be read by the angular search/filter. If I backspace once... or change the value in any way, it kicks in.
How can I shove a value in there have angular read it as if I had typed it in? Not sure of the right words to use. Thanks. There is more code, but I think that this will be enough to see what my issue is. Let me know if that is not the case.. Thanks.
http://codepen.io/sheriffderek/pen/dtAIy/
Here is a codepen. It's not really the same because it is sandboxed into one page, and also the local storage is effected. BUT. If my question is at all clear, it should be enough code.
Man makes angular filtered search. Man takes string. Man puts sting into the search input. Search does not reflect change.
select html
<select name='state' id='state_select'>
<option value='state-name' data-state='California'>California</option>
<option value='state-name' data-state='Arizona'>Arizona</option>
<option value='state-name' data-state='New York'>New York</option>
<option value='state-name' data-state='Utah'>Utah</option>
</select>
css (irrelevant)
/* n/a */
action js
var getTheState = function(input) {
var theState = $(input).data('state');
localStorage.setItem('state', theState);
console.log(theState);
};
$('#state_select').on('change', function() {
if (this.selectedIndex!==0) {
var destinationPage = "search.html";
getTheState('option:selected');
document.location.href = destinationPage;
}
});
the gist of the angular
<input type="search" data-ng-model="listingFilter" />
<ul class='things-list' data-ng-controller='DetailedNameOfController as listOf'>
<li class='thing' data-ng-repeat='thing in listOf.things | search:listingFilter'>
{{ thing.name | filter: name }}
</li>
</ul>