简体   繁体   中英

AngularJS - Bind input to value with filter and update it

I have an input bound to an object property and with a filter applied to it.

<input value="{{object.field | filter}}">

The problem is that if I programmatically change object.field , the value displayed inside the input doesn't change , however in the DOM Inspector I see the correct (new) value. I verified to digest/apply the changes to the scope and the object.field variable does change correctly, the issue seems to be only in the input displayed value.

I cannot provide an example since there's too much code involved.

Does anyone know where I should look for errors??

No need to set value in that way. ng-model takes care of it. Valid syntax is:

<input ng-model="object.field">

For filtering you can look at this answer: Using angularjs filter in input element

我认为您应该使用ng-model将数据绑定到输入框中,而不要使用{{expression}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM