首页 > 解决方案 > Angular Froala _this._$element.froalaEditor 不是函数

问题描述

我已经阅读了 SO 和 git 上的所有答案,以弄清楚为什么 froalaEditor 在我的项目中不起作用。

这是我的设置:

我已经通过使用安装了插件

npm install angular-froala-wysiwyg --save

然后在我的 .angular-cli.json 中:

"styles": [
    "styles.scss",
    "../node_modules/froala-editor/css/froala_editor.pkgd.min.css",
    "../node_modules/froala-editor/css/froala_style.min.css"
  ],
"scripts": [
    "../node_modules/froala-editor/js/froala_editor.pkgd.min.js"

  ],

然后在我的模块中:

import {FroalaEditorModule, FroalaViewModule} from 'angular-froala-wysiwyg';

 @NgModule({
    imports: [
        HttpClientModule, CommonModule, RouterModule.forChild(routes), LayoutModule, FormsModule, ReactiveFormsModule, DropzoneModule,
        FroalaEditorModule.forRoot(), FroalaViewModule.forRoot()

    ], exports: [
        RouterModule,
    ], declarations: [
        ContentMakerComponent,
        VideoElementComponent,
        TextElementComponent,
        MultipleChoiceElementComponent,
        SoundElementComponent,
        DocumentElementComponent
    ],
    providers: [
        {
            provide: DROPZONE_CONFIG,
            useValue: DEFAULT_DROPZONE_CONFIG
        }
    ]
})

然后在我的组件中:

<div [froalaEditor]>Hello, Froala!</div>

现在,每当我打开组件时,我都会得到:

ERROR TypeError: _this._$element.froalaEditor is not a function
at eval (editor.directive.js:167)
at ZoneDelegate.invoke (zone.js:388)
at Zone.run (zone.js:138)
at NgZone.runOutsideAngular (core.js:4708)
at FroalaEditorDirective.createEditor (editor.directive.js:166)
at FroalaEditorDirective.ngOnInit (editor.directive.js:244)
at checkAndUpdateDirectiveInline (core.js:12411)
at checkAndUpdateNodeInline (core.js:13935)
at checkAndUpdateNode (core.js:13878)
at debugCheckAndUpdateNode (core.js:14771)

任何人都可以帮忙吗?

标签: angularangular5froala

解决方案


推荐阅读