【问题标题】:angular injector error with config()配置()的角度喷射器错误
【发布时间】:2017-09-13 06:49:42
【问题描述】:

我想将配置注入到我的 Angular 应用程序中。该应用程序还包含一个运行对象。

但是当我添加配置选项时,我得到一个 $injector:modulerr 错误。而且我找不到错误。

var myApp = angular.module('myApp',[
    'ngAnimate',
    'ui.bootstrap',
    'ui.router',
    'angular.filter',
    'angularUtils.directives.dirPagination',
    'validation.match',
    'ngSanitize',
    'ngCookies',
    'pascalprecht.translate',
    'toggle-switch',
    'angucomplete-alt',
    'cgPrompt',
    'dndLists',
    'ngFileUpload',
    'ui.router.breadcrumbs',
    'angular-bind-html-compile',
    'rzModule', // range slider (i.e. for price filter)
    'ngFileSaver',
    'angular-input-stars',
    'textAngular',
    'textAngular-uploadImage'
]);

myApp.config(function($provide) {
    $provide.decorator('taOptions', function($delegate) {
        $delegate.toolbar[1].push('uploadImage');
        return $delegate;
    });
});


myApp.run(['$rootScope', '$window', '$location', '$stateParams', '$api', '$translate', '$transitions', '$state',
    function($rootScope, $window, $location, $stateParams, $api, $translate, $transitions, $state) {
        //rootscope
}]);

关于 textAngular-uploadImage 模块 (https://github.com/mrded/textAngular-uploadImage)。当我删除配置选项时,我的应用程序运行良好,但当然,我不能使用该模块。

这是什么原因?我在 html 中包含了所有必需的文件,textAngular (https://github.com/textAngular/textAngular) 工作正常。

我该如何解决这个问题?或者 textAngular 中的普通上传功能还有其他选项吗?我也尝试了这个解决方案 (https://github.com/textAngular/textAngular/issues/139#issuecomment-111205679),但我得到了同样的错误。

【问题讨论】:

  • 你试过 myApp.config(['$provide',function($provide){ //code here }])
  • 您没有提供完整的错误信息。它包含解析它的所有必要信息(它实际上是一个指向以可读形式显示它的页面的 URL)。

标签: angularjs textangular


【解决方案1】:

试试下面的代码..

myapp.config(['$provide', function($provide){

    $provide.decorator('taOptions', ['$delegate', function(taOptions){
    taOptions.toolbar[1].push('uploadImage');
    }
    return taOptions;
    }];
    });

您需要使用编辑器注册上传图片,如下所示

taRegisterTool('uploadImage', {
        iconclass: "fa fa-user",
        action: function(){
            //code
        }
    });

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2016-09-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-04
  • 2017-04-07
  • 1970-01-01
相关资源
最近更新 更多