angular-datepicker icon indicating copy to clipboard operation
angular-datepicker copied to clipboard

date-change doesn't work at all

Open arti040 opened this issue 8 years ago • 13 comments

Callback inside my controller:

functionToFire() { console.log('Yo!'); }

Template:

<div
      date-picker
      ng-model = "$ctrl.scheduleDate"
      min-date = "$ctrl.today"
      view = "date"
      min-view = "date"
      max-view = "date"
     date-change = "$ctrl.functionToFire" 
    >
</div>

I tried on-set-date either but w/o success. Using Angular 1.5, date-picker is inside component.

arti040 avatar Apr 20 '16 11:04 arti040

Actually, because this directive uses it's own scope, ng-change is not available too.

volodymyrlut avatar Jul 26 '16 08:07 volodymyrlut

any solution ?

troynsky avatar Aug 05 '16 14:08 troynsky

any solution ?

Nope :/

— Regards, Piotr.

arti040 avatar Aug 05 '16 14:08 arti040

Somebody know, which version I can take where this function is work ?

troynsky avatar Aug 05 '16 14:08 troynsky

You can watch the model or set up an ng-click on date-picker. It's not pretty but does the job. With ng-click you can sort of assume that date change came from user clicking on the picker.

kfurmann avatar Aug 19 '16 09:08 kfurmann

Will this critical issue be fixed? Or package not maintained any more?

Deadly0 avatar Nov 25 '16 15:11 Deadly0

Has this ever been fixed? for me its not firering at all either..

ro8in avatar Feb 22 '17 14:02 ro8in

Someone has fixed it ?

leonardors95 avatar Feb 22 '17 20:02 leonardors95

I have had a look at this problem, and while I was able to get the callback firing without any changes to the library, there appears to be a scoping issue. The called function scope is not the component controller, but is instead the datepicker scope.

See this plunkr for an illustration of the problem. Note that while the callback function fires, the text doesn't update because in the called function this refers to the wrong object.

Here is a copy of the above plunkr with the issue fixed in the library. Note that when the callback is fired, this now refers to the correct object.

I will make a PR with this fix when I get a chance.

DanTalash avatar Feb 23 '17 00:02 DanTalash

When I downloaded this script from the site instead of using the NPM version it started working..

ro8in avatar Feb 23 '17 09:02 ro8in

@ro8in what script and site ?

leonardors95 avatar Feb 23 '17 11:02 leonardors95

I meand this datepicker module.. When I take the NPM version it doesnt work but I download the latest from github it works.

ro8in avatar Feb 23 '17 11:02 ro8in

Hi, sorry to bump an old issue, but was there a workaround for this? I want the ability to allow the user to type in a date and update the UI automatically like the live demo, but I seem to be suffering from the issue referenced above because of scoping issues.

Using "angular-datepicker": "^1.0.5" on npm if it helps.

mdhari avatar Mar 08 '18 04:03 mdhari