无法绑定到“ owlDateTimeTrigger”,因为它不是“ span”的已知属性

时间:2019-11-16 08:30:37

标签: angular typescript

我正在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> 

1 个答案:

答案 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 { }