Hi I have a form that is searchable when entering in data to textboxes and
then clicking a submit button. It works perfectly the first time through,
but when I try to clear out the values and do a second search it starts to
display data without a button click. It does the two-way binding just by
typing in the text box. I need it to only work when the button is clicked.
Here's my code:
HTML
<form name="form" id="form" novalidate>
<div>
<input ng-model="searchModel.address" />
<input ng-model="searchModel.city" />
<button type="submit" ng-click="filterSearch =
searchModel">Search</button>
<button type="reset">Reset</button>
<table>
<thead>
<tr>
<th>
Address
</th>
<th>
City
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="search in vm.searches | filter:{'address':
filterSearch.address, 'city': filterSearch.city}">
<td>
{{ search.address }}
</td>
<td>
{{ search.city }}
</td>
</tr>
</tbody>
</table>
</div>
</form>
Controller:
(function () {
'use strict'
angular
.module('crm.ma')
.controller('AdvancedSearchCtrl', AdvancedSearchCtrl);
function AdvancedSearchCtrl() {
var vm = this;
vm.searches = [
{
"address": "202 This St",
"city": "Columbus"
},
{
"address": "205 That St",
"city": "Dayton"
}
];
}
vm.SearchModel = function () {
var vm = this;
vm.filterSearch = angular.copy(searchModel);
};
})();
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.