javascript - angularJS emptying input field on filter -
today faced situation angularjs.
hi have recipe website, , list ingredients , theyr respective dosage i'm using angular's ng-repeat (here goes snippet).
<div ng-repeat="food in foodlist | filter:query"> <label> {{food.name}} </label> <input type="text" class="form-control food-list-input" data-id="{{food.ingredientid}}" placeholder="weight in grams."> </div>
the thing when apply filter, inputs inserted value, if hidden because of filter, return empty.
is there anyway around this?
i think want bind input using ng-model
, example:
<input type="text" ng-model="food.dosage" class="form-control food-list-input" data-id="{{food.ingredientid}}" placeholder="weight in grams.">
that implement two-way binding model input
tag, when ng-repeat
re-runs, entered values re-bound model.
Comments
Post a Comment