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

Max*_*erg 2 leaflet leaflet.markercluster ngx-leaflet

我在angular 5应用程序中使用ngx-leaflet-markercluster。我根据演示更改了代码,但仍然收到以下错误:

无法绑定到“ leafletMarkerCluster”,因为它不是“ div”的已知属性。

有任何想法吗?有人尝试过v1.0.0吗?

reb*_*ace 5

确保将导入LeafletMarkerclusterModule到应用程序的适当模块中(类似于对ngx-leaflet模块所做的操作)。此错误通常是由于Angular不知道指令而引起的,因为尚未导入模块。

例如,确保使用ngx-leaflet和ngx-leaflet-markercluster的模块看起来类似于以下内容:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { LeafletModule } from '@asymmetrik/ngx-leaflet';
import { LeafletMarkerClusterModule } from '@asymmetrik/ngx-leaflet-markercluster';

@NgModule({
    imports: [
        CommonModule,
        FormsModule,

        LeafletModule.forRoot(),
        LeafletMarkerClusterModule.forRoot()
    ],
    declarations: [
        MyComponent
    ],
    exports: [
        MyComponent
    ],
    bootstrap: [ MyComponent ],
    providers: [ ]
})
export class MyModule { }
Run Code Online (Sandbox Code Playgroud)

  • 这怎么不在文档中.....即使很明显,我还是完全忘记了 (2认同)