angular ui bootstrap datepicker causes "infdig"

656 views Asked by At

I'm trying to apply the datepicker from angular ui in my application but for some reason it results in the following error:

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [] http://errors.angularjs.org/1.3.15/$rootScope/infdig?p0=10&p1=%5B%5D

I don't understand why this error is triggered because. In the link above the description reads:

This error occurs when the application's model becomes unstable and each $digest cycle triggers a state change and subsequent $digest cycle. Angular detects this situation and prevents an infinite loop from causing the browser to become unresponsive.

I don't see how this is applicable to my situation at all.

If I'm using a regular input field like this:

<input type="text" class="form-control" id="my-date" name="myDate" data-ng-model="ctrl.myDate"
                                       data-ng-model-options="{updateOn: 'blur'}" data-ng-change="ctrl.changeDetected()" >

There's no problem and the date is displayed just fine, but this:

<p class="input-group">
    <input type="text" class="form-control" datetime-picker="'yyyy-MM-dd'" data-ng-model="ctrl.myDate" data-is-open="ctrl.isOpen" data-enable-time="false" data-show-button-bar="false" data-timepicker-options="ctrl.dateOptions" />
    <span class="input-group-btn">
        <button type="button" class="btn btn-default" data-ng-click="ctrl.openCalendar($event, date)"><i class="fa fa-calendar"></i></button>
    </span>
</p>

will result in the error. Can someone smarter than me give me a pointer as to what it is that I'm missing. I'm just loading the date from the backend and trying to display it as the current date in a datepicker.

/Regards Kris

1

There are 1 answers

0
Kristofer On

Sorry, apparently I'm a dumbass. there's nothing wrong with the datepicker and the code above. I had missed that the surrounding div was using a validation directive that was bound to the name attribut of the input field and I forgot to add this name attribut to the corresponding datepicker input field.