Search code examples
angularjstextangular

angular injector error with config()


I want to inject a config into my angular app. The app contains also an run object.

But when I add the config option I get an $injector:modulerr error. And I can't find the error.

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
}]);

It's going about the textAngular-uploadImage module (https://github.com/mrded/textAngular-uploadImage). When I remove the config option my app runs fine, but of course, I can't use the module.

What is the reason for this? I included al the required files in the html, and textAngular (https://github.com/textAngular/textAngular) is working fine.

How can I solve this? Or are there any other options for a normal upload function in textAngular? I also tried this solution (https://github.com/textAngular/textAngular/issues/139#issuecomment-111205679) but I get the same error.


Solution

  • Try something below code..

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

    And you would need to register upload image with editor like below

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