2017-09-13 85 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