2017-09-13 65 views
2

我想注入一个配置到我的角度应用程序。该应用程序还包含一个运行对象。配置角度注射器错误()

但是当我添加配置选项时,我得到一个$ 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),但我得到了同样的错误。

+0

你尝试myApp.config([ '$提供',函数( $ provide){// code here}]) – Nikita

+0

您尚未提供完整的错误讯息。它包含解决它的所有必要信息(它实际上是一个导致页面显示为可读形式的URL)。 – estus

回答

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 
     } 
    }); 
+0

谢谢。它是'''''提供',函数($提供)'出了什么问题。我现在有解决方案从https://github.com/textAngular/textAngular/issues/139#issuecomment-111205679工作! – NVO