I have a DTO object that has a Date parameter. I wrap this Dto in a view model object, whose properties I then bind in my view to the label.
<label class="form-control">{{controller.ViewModel.Date}}</label>
In the view model, I have a getter. (I am using TypeScript)
public get Date(): Date { return new Date(Date.parse(this.dto.Date));
emitted javascript:
Object.defineProperty(ViewModel.prototype, "Date", { get: function () { return new Date(Date.parse(this.dto.Date)); }, enumerable: true, configurable: true });
I believe that the reason I create a new date in getter and angular believes that this means the dates are always new, and it continues to get the date until the model stabilizes, which will cause an infinite loop.
Why does angular do this?
Why does he keep calling the getter again and again, what's wrong, just calling him once?
Can I tell angular to just call the receiver once and accept the value that it is given?
source share