问题描述: 在使用Angular Bootstrap的ngbtimepicker组件时,无法通过模型来设置时间选择器的值。
解决方法:
timeValue: Date = new Date();
完整示例代码: component.html:
component.ts:
import { Component } from '@angular/core';
import { NgbTimeStruct } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-timepicker',
templateUrl: './timepicker.component.html',
styleUrls: ['./timepicker.component.css']
})
export class TimepickerComponent {
timeValue: Date = new Date();
}
这样,就可以通过模型来设置ngbtimepicker的值了。