【问题标题】:Angular JS ui-tinymceAngular JS ui-tinymce
【发布时间】:2014-11-05 10:21:16
【问题描述】:

我在 Angular 项目中使用 ui-tinymce 模块。在一个控制器中称为tinymce.execCommand('mceRemoveControl', true, 'ntContent');,这工作正常。但是在 grunt build 命令之后,我收到以下错误:ReferenceError: tinymce is not defined。有人可以帮忙吗?

【问题讨论】:

  • 听起来好像不包括 tinymce javascript 依赖项。它不能在任何地方声明的“tinymce”变量。检查以确保在运行所有 Angular 代码之前加载 tinymce javascript 文件。
  • 尝试在你的页面头中直接包含cdn

标签: angularjs tinymce angular-directive


【解决方案1】:

我在 angular-ui-tinymce 模块中遇到了同样的问题,我通过确保包含该文件来解决此问题。

<script src="bower_components/tinymce-dist/tinymce.min.js"></script>
<script src="bower_components/angular-ui-tinymce/src/tinymce.js"></script>

这个脚本被插入到 index.html 文件bower install angular-ui-tinymce 中,并且源代码被下载并放置在适当的位置。

此外,当您在复制任务上运行 grunt build 时,它不会从 /tinymce-dist文件夹复制所需的文件,解决方案是手动添加到 复制任务 以复制您的文件夹需要。我必须在复制任务中将以下代码插入到 grunt.js 文件中,从而将 /skins /themes /plugins 文件夹直接复制到 dist/scripts 文件夹中:

// Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          ...
        }, {
          ...
        }, {
          expand: true,
          cwd: 'bower_components/tinymce-dist/themes/modern/',
          src: ['**'],
          dest: '<%= yeoman.dist %>/scripts/themes/modern/'
        }, {
          expand: true,
          cwd: 'bower_components/tinymce-dist/skins/',
          src: ['**'],
          dest: '<%= yeoman.dist %>/scripts/skins/'
        }, {
          expand: true,
          cwd: 'bower_components/tinymce-dist/plugins/link/',
          src: ['**'],
          dest: '<%= yeoman.dist %>/scripts/plugins/link/'
        }]
      },
      styles: {
        ...
      }
    }

这不是有史以来最好的解决方案,但它对我有用,希望它对某人有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多