Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular ngb datepicler中更改事件的更改日期_Angular_Ng Bootstrap_Ngb Datepicker - Fatal编程技术网

Angular ngb datepicler中更改事件的更改日期

Angular ngb datepicler中更改事件的更改日期,angular,ng-bootstrap,ngb-datepicker,Angular,Ng Bootstrap,Ngb Datepicker,我有这个范围选择弹出从ngb日期选择器。 我从后端得到了初始日期,一切正常。但是当我更新日期时,它在输入字段中没有改变。如何修复此错误 我添加了TS文件,这与给定的exmaple相同。但我认为TS文件没有问题 onDateSelection(date: NgbDate) { if (!this.fromDate && !this.toDate) { this.fromDate = date; } else if (this.fromDate &

我有这个范围选择弹出从ngb日期选择器。 我从后端得到了初始日期,一切正常。但是当我更新日期时,它在输入字段中没有改变。如何修复此错误


我添加了TS文件,这与给定的exmaple相同。但我认为TS文件没有问题

  onDateSelection(date: NgbDate) {
    if (!this.fromDate && !this.toDate) {
      this.fromDate = date;
    } else if (this.fromDate && !this.toDate && date && date.after(this.fromDate)) {
      this.toDate = date;
    } else {
      this.toDate = null;
      this.fromDate = date;
    }
  }

  isHovered(date: NgbDate) {
    return this.fromDate && !this.toDate && this.hoveredDate && date.after(this.fromDate) && date.before(this.hoveredDate);
  }

  isInside(date: NgbDate) {
    return this.toDate && date.after(this.fromDate) && date.before(this.toDate);
  }

  isRange(date: NgbDate) {
    return date.equals(this.fromDate) || (this.toDate && date.equals(this.toDate)) || this.isInside(date) || this.isHovered(date);
  }

  validateInput(currentValue: NgbDate | null, input: string): NgbDate | null {
    const parsed = this.formatter.parse(input);
    return parsed && this.calendar.isValid(NgbDate.from(parsed)) ? NgbDate.from(parsed) : currentValue;
  }
下一步

  • 使用
    (值)
    代替
    [(ngModel)]
  • 删除
    [ngModelOptions]=“{updateOn:'blur'}”
  • 在选择日期时手动关闭数据采集器

  • 请共享ts文件code@DeepuReghunath我已添加ts文件,请帮助。什么是
    splitRuleDetail
    ?无法在ts文件中找到
         onDateSelection(date: NgbDate) {
        if (!this.fromDate && !this.toDate) {
          this.fromDate = date;
        } else if (this.fromDate && !this.toDate && date && date.after(this.fromDate)) {
          this.toDate = date;
          this.sub.close();  // close manually
        } else {
          this.toDate = null;
          this.fromDate = date;
        }
    
      }
    
      isHovered(date: NgbDate) {
        return this.fromDate && !this.toDate && this.hoveredDate && date.after(this.fromDate) && date.before(this.hoveredDate);
      }
    
      isInside(date: NgbDate) {
        return this.toDate && date.after(this.fromDate) && date.before(this.toDate);
      }
    
      isRange(date: NgbDate) {
        return date.equals(this.fromDate) || (this.toDate && date.equals(this.toDate)) || this.isInside(date) || this.isHovered(date);
      }
    
      validateInput(currentValue: NgbDate | null, input: string): NgbDate | null {
        const parsed = this.formatter.parse(input);
        return parsed && this.calendar.isValid(NgbDate.from(parsed)) ? NgbDate.from(parsed) : currentValue;
      }