mardi 17 février 2015

require confirmation before updating ng-model or executing ng-change in angularjs checkbox input

I have a checkbox input that when checked sets customer.isCompleted to true or false and saves the customer data through a firebase api using ng-change


input type="checkbox" ng-model="customer.isCompleted" ng-change="sc.data.$save(customer)"


however i want to make sure when customer checks the box, it prompts for confirmation. If users hits OK then, it should check the box, update the ngModel and fire ngChange otherwise do nothing.(and do this when the box is checked or unchecked). when checked the confirmation box should say message1 and when unchecked it should say message2.


how can I implement this. I'm assuming a directive, but don't know how i'd implement it.





Aucun commentaire:

Enregistrer un commentaire