Angularjs send value to database when leaving input field
Asked Answered
H

1

9

Been looking around but i can't seem to find any good resources. Got an application where i want to update the data in the database once the user leaves the textbox/area etc., figured i could probably do this with the ngfocus event but i would also need to get which field has triggered the update.

Not sure on how to proceed, might not event be the best thing to use ngfocus. Perhaps creating a new directive or maybe extending ngfocus if possible. Any suggestions are appreciated.

Heteronomy answered 1/3, 2014 at 15:28 Comment(1)
I would create a new directive that uses .blur - attach it to your input element and then call your service from that.Oxidate
C
17

Use ngBlur instead.

HTML:

<input ng-blur='sendData()' />

Just make sure your controller exposes a sendData method on the scope.

Cotidal answered 1/3, 2014 at 16:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.