0

I want to write some code on selection of Date in Angular UI Boostrap DatePicker.

I tried using ng-change event as below. but it doesn't call when date is not changed. Even if we can detect close event of popup that will also be helpful.

ctrl.changeDate = function() {
    console.log('called date');
}

My HTML Code

<input type="text" class="form-control" 
    uib-datepicker-popup="{{'dd/MM/yyyy'}}"
    ng-model="$ctrl.model[$ctrl.name]"  
    ng-show="$ctrl.editMode"
    is-open="$ctrl.popup1.opened"
    datepicker-options="{dateDisabled: disabled,formatYear: 'yy',startingDay: 1}"
    close-text="Close" 
    alt-input-formats="['dd/MM/yyyy']" 
    ng-focus="$ctrl.open1()"
    ng-change="$ctrl.changeDate()" 
/>

1 Answer 1

1

watch opened property for detect close event

$scope.$watch('$ctrl.popup1.opened',function(newVal, oldVal){
    if(newVal != oldVal && !newVal){
         //close event
    }
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.