Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Is there a way to disable one-time binding for day labels? #4692

Closed
Badabum opened this issue Oct 22, 2015 · 5 comments
Closed

Is there a way to disable one-time binding for day labels? #4692

Badabum opened this issue Oct 22, 2015 · 5 comments

Comments

@Badabum
Copy link

Badabum commented Oct 22, 2015

I tried to dynamicaly change locale in datepicker following this approach:

 angular.module('ui.bootstrap.datepicker')
.config(function ($provide) {
    $provide.decorator('datepickerDirective', function ($delegate) {
        angular.forEach($delegate, function (directive) {
            var originalCompile = directive.compile;
            var originalLink = directive.link;
            console.log($delegate);
            if (originalCompile) {
                directive.compile = function () {
                    return function (scope, element, attrs, ctrls) {
                        var datepickerCtrl = ctrls[0];
                        scope.$on('$localeChangeSuccess', function () {
                            scope.move(0);
                            datepickerCtrl.refreshView();

                        });
                        originalLink.apply(this, arguments);
                    };
                }
            }
        });
        return $delegate;
    });
});

But I found that this is not working because of one-time binding for day labels. So is there a way to disable one-time binding without the need of modifying template? I use 0.13.2 version.

@wesleycho
Copy link
Contributor

I would recommend modifying the template for now - this is a valid feature request for adding support for i18n updating of the view, so I am tagging this with the fresh i18n label.

@wesleycho wesleycho added this to the Backlog milestone Oct 22, 2015
@icfantv icfantv mentioned this issue Nov 10, 2015
@SandeepThomas
Copy link

Can someone please explain what modification needs to be done in the template to translate datepicker?

@Badabum Badabum closed this as completed Nov 20, 2015
@Badabum
Copy link
Author

Badabum commented Nov 20, 2015

@SandeepThomas , just delete one time bindings ('::') for day labels. Also you need to reload datepicker when locale changed if you use angular-translate lib.

@Badabum Badabum reopened this Nov 20, 2015
icfantv referenced this issue Dec 16, 2015
Reducing the number of watches created for the
datepicker by implementing one time binding
on the datepicker templates. Removing aria-disabled
attribute as the ngAria module will add that
to the button with ng-disabled.

Closes #3443
@wesleycho
Copy link
Contributor

Closing this in favor of #4626, I have figured out a solution to this issue that will be implemented as detailed there.

@zsitro
Copy link

zsitro commented Jun 16, 2016

Possible workaround: $scope.$watch for value changes and broadcast a calendar redraw with help of this guide: https://gist.github.com/cgmartin/3daa01f910601ced9cd3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants