I am trying to set a max date of today like this:
My controller:
vm.maxDate= maxDate;
function maxDate() {
return new Date((new Date()).getFullYear(), (new Date()).getMonth(), (new Date()).getDate());
}
My HTML:
<md-datepicker
md-placeholder="Date of Creation"
md-max-date="myCtrl.maxDate()"
ng-model="myCtrl.form.startDate">
</md-datepicker>
It is working as expected and user is not able to select anything after maxDate. But as soon as I write md-max-date="myCtrl.maxDate()" in my html, I get this angular error. I don't know why this is happening. Any help will be appreciated. Thanks
This is the link to the error Link To Error
This is the error:
Error: $rootScope:infdig Infinite $digest Loop
10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [[{"msg":"fn: function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}","newVal":"2017-06-18T04:00:00.000Z","oldVal":"2017-06-18T04:00:00.000Z"}],[{"msg":"fn: function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}","newVal":"2017-06-18T04:00:00.000Z","oldVal":"2017-06-18T04:00:00.000Z"}],[{"msg":"fn: function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}","newVal":"2017-06-18T04:00:00.000Z","oldVal":"2017-06-18T04:00:00.000Z"}],[{"msg":"fn: function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}","newVal":"2017-06-18T04:00:00.000Z","oldVal":"2017-06-18T04:00:00.000Z"}],[{"msg":"fn: function (c,e,f,g){f=d&&g?g[0]:a(c,e,f,g);return b(f,c,e)}","newVal":"2017-06-18T04:00:00.000Z","oldVal":"2017-06-18T04:00:00.000Z"}]]