How can I make getter and setter work in my model class?
My goal is to calculate integer value of the selected day when input, containing the date, updated. I was going to do it in setter, but Angular 4 ignores setter and getter of my model.
My model class:
export class MyModel {
@Input('date')
get date(): String {
console.log('Getting date');
...
}
set date(val) {
console.log('Setting date: ' + val);
...
}
}
My template:
...
<input class="form-control" name="dp" [(ngModel)]="model.date">
...
But getter and setter don't work. What am I missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…