katemihalikova / ion-datetime-picker

Date and/or time picker for awesome Ionic framework
MIT License
169 stars 101 forks source link

onChange & onCancel attributes #67

Closed WilliamDASILVA closed 7 years ago

WilliamDASILVA commented 7 years ago

Hello there,

I needed to detect whenever the user clicks on 'OK' or 'Cancel'. Using $watch on the model wasn't ok for me for multiple reasons. So I added two more attributes 'on-change=' and 'on-cancel='.

<span ng-model="myDate" ion-datetime-picker on-change="myFunction" on-cancel="cancelFunction">

In controller:

$scope.myFunction = function(newDate){
}

$scope.cancelFunction = function(){
}
katemihalikova commented 7 years ago

Hi William, thanks for your code!

Unfortunately change event is already implemented using standard ng-change and I can't see any potential in supporting cancel event. I would consider it when there is more demand for it and also consider adding it for the next major version.

If you really want to use it, you can add WilliamDASILVA/ion-datetime-picker#feature/events to your bower.json file to pull your branch.

Thanks anyway, good job!

katemihalikova commented 7 years ago

I see that you are using "=?" attribute signature for events. You should be using "&" instead, but that would require a little code change in the picker. Just an idea :)