Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Very strange issue - is it because of ngCloak?
Message
De
09/08/2017 04:26:25
 
 
Information générale
Forum:
AngularJS
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01653152
Message ID:
01653162
Vues:
39
This message has been marked as a message which has helped to the initial question of the thread.
ngCloak shouldn't be a factor.

ng-show expects a bool and 'BirthDate' returns a string although, since it appears that the label is showing, that's probably not the root of the problem.

I'd suspect that having ' ng-model="currentData.birthDate" ' and ' data-date-change="birthDateChange" ' (which can also set 'currentData.birthDate) on the datepicker may be the problem - it could be causing multiple digest cycles.


>UPDATE. I think I'll try to get rid of the 'BirthDate' property at all. Would it work if I use currentData.birthDate instead?
>
>UPDATE2. Still seems to be the delay.
>
>
>Hi everybody,
>
>I'm experiencing a weird problem. We have a very complex directive smDateTimePicker. This directive is also used in the smContact directive which is using the following at the top
>
>
><ng-form name="contactInfo" ng-cloak>
>
>and in the middle
>
>
><div class="col-xs-8">
>                        <div class="form-inline">
>                            <div class="form-group">
>                                <label class="control-label">@Labels.birthDate:</label>
>                            </div>
>                        </div>
>                        <div class="form-group">
>                            <data-sm:date-time-picker name="birthDate"
>                                                      ng-model="currentData.birthDate"
>                                                      form="contactInfo"
>                                                      data-date-change="birthDateChange"
>                                                      data-only-past-dates="true" />
>                        </div>
>                        <div class="form-group">
>                            <label ng-show="BirthDate">(@Labels.age: {{currentData.age}})</label>
>                        </div>
>                    </div>
>
>The BirthDate is defined this way in the smContact.js:
>
>
>Object.defineProperty($scope,
>                    "BirthDate",
>                    {
>                        get: function () {
>                            if ($scope.currentData && $scope.currentData.birthDate) {
>                                if (moment.isMoment($scope.currentData.birthDate)) {
>                                    return $scope.currentData.birthDate.format(services.Date.DATE_FORMAT);
>                                }
>
>                                return moment($scope.currentData.birthDate, [services.Date.DATE_FORMAT, services.Date.SERVER_FORMAT]).format(services.Date.DATE_FORMAT);
>                            }
>
>                            return "";
>                        }
>                    });
>
>The birthDateChange method has the following code now:
>
>
> /**
>                 * 
>                 * @param {any} newValue
>                 */
>                $scope.birthDateChange = function (newValue) {
>                    $log.debug("birthDateChange method called with the newValue=" + newValue);
>                    $scope.currentData.age = 0;
>                    // $log.debug("$scope.currentData.birthDate is : " + $scope.currentData.birthDate);
>                    //$log.debug("newValue is : " + newValue);
>                    if (newValue != null) {
>                        let age = moment().diff(moment(newValue, [services.Date.DATE_FORMAT]), "years");
>                        if (age >= 0) {
>                            $scope.currentData.age = age;
>                        }
>                        else {
>
>                            $log.debug("Birthday Changed and age is now incorrectly calculated as " + age);
>                        }
>                    }
>                    else {
>                        $scope.currentData.birthDate = null;
>                    }
>                }
>
>Here is what is happening. I remove the current date and I can see my message in the developer's console about calling that method with newValue = null. However, I count to ~25 before the age disappears from the view. It doesn't change to 0 either. If it was 51 before I removed the value from date time picker, it remains showing 51 for about 25 sec., then flashes as 0 and then disappears at all (as BirthDate is "").
>
>Therefore, somewhere the timeout is in effect. The smDateTimePicker used to have a timeout function, but I commented it out a while ago and refreshed the cache many times since then. Still that's the behavior which is quite puzzling.
>
>Perhaps the regular user will not pay that much attention, but for me it's strange - why the age doesn't immediately update as well?
>
>Thanks in advance.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform