[英]Angular ngbDatepicker: How to include context in markDisabled
I have an input field defined as ngbDatepicker.我有一个定义为 ngbDatepicker 的输入字段。 Some of the days should be disabled which is why I use [markDisabled]="getDisabledDays" like this:
有些日子应该被禁用,这就是我像这样使用 [markDisabled]="getDisabledDays" 的原因:
<input type="text" [minDate]="getMinDate()"
[maxDate]="maxDate" formControlName="deliverydate" #d="ngbDatepicker"
[markDisabled]="getDisabledDays" (click)="d.toggle()" required>
getDisabledDays = function (date: NgbDate, current: { month: number }) {
//returns hardcoded NgbDateStruct[] array with the days.
}
Till now I had an hardcoded NgbDateStruct[] with the disabled days.到现在为止,我有一个硬编码的 NgbDateStruct[] 与禁用的日子。 I now want to fill that array dynamically which is why I have to access the components context by using "this".
我现在想动态填充该数组,这就是为什么我必须使用“this”访问组件上下文的原因。 However, "this" is undefined in the functions scope and I cant access the properties I need.
但是,“this”在函数 scope 中未定义,我无法访问我需要的属性。 How can I solve that?
我该如何解决?
SOLUTION :解决方案:
As suggested by Eliseo:正如Eliseo所建议的:
getDisabledDays = (date: NgbDate, current: { month: number })=> { console.log(this.days)} getDisabledDays = (日期:NgbDate,当前:{ 月:数字 })=> { console.log(this.days)}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.