我正在OwlDateTimeModule
中使用smart-table-datepicker
。我已将其导入smart-table-datepicker.module
中。我已经遵循了一些答案,但是它仍然显示错误。我在做什么错了?
smart-table-datepicker.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SmartTableDatepickerComponent, SmartTableDatepickerRenderComponent } from './smart-table-datepicker.component';
import { OwlDateTimeModule, OwlNativeDateTimeModule } from 'ng-pick-datetime';
@NgModule({
declarations: [SmartTableDatepickerComponent],
imports: [
CommonModule,
OwlDateTimeModule,
OwlNativeDateTimeModule,
],
exports: [
SmartTableDatepickerRenderComponent,
SmartTableDatepickerComponent
]
})
export class SmartTableDatepickerModule { }
smart-table-datepicker.component.html
<div class="input-group">
<span [owlDateTimeTrigger]="dt" class="input-group-addon"><i class="fa fa-calendar"></i></span>
<input
[owlDateTimeTrigger]="dt" [owlDateTime]="dt"
[(ngModel)]="inputModel"
placeholder="{{placeholder}}"
[min]='min' [max]='max'
readonly
class="form-control">
</div>
<owl-date-time #dt [stepMinute]="15" [hour12Timer]='true' (afterPickerClosed)="onChange()"></owl-date-time>
答案 0 :(得分:0)
似乎您已导入模块SmartTableDatepickerModule
中,但是尚未将import { OwlDateTimeModule, OwlNativeDateTimeModule } from 'ng-pick-datetime';
导入您的组件中:
your-component.ts
import { Component, ChangeDetectionStrategy } from '@angular/core';
.............
import { OwlDateTimeModule, OwlNativeDateTimeModule } from 'ng-pick-datetime';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
@component({
selector: 'fooComponent',
templateUrl: 'your-component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class YourComponent{
public dateTime: Date;
}
更新:
如果在其他模块中使用了此模块,则需要提供一种将其代码用于其他库的方法。因此,只需导出它们:
@NgModule({
declarations: [SmartTableDatepickerComponent],
imports: [
CommonModule,
OwlDateTimeModule,
OwlNativeDateTimeModule,
],
exports: [
SmartTableDatepickerRenderComponent,
SmartTableDatepickerComponent,
OwlDateTimeModule,
OwlNativeDateTimeModule,
]
})
export class SmartTableDatepickerModule { }