无法在app config中获取dialogsProvider

时间:2017-09-03 14:09:50

标签: angularjs

在我的app配置中,我想注入并使用dialogsProvider

app.config.js

import app from './app.module';

app.config(['$compileProvider', '$filterProvider', '$provide', '$httpProvider',
            'dashboardResolverProvider','dialogsProvider', 'localStorageServiceProvider','ROUTER',
            '$translateProvider',

    function ($stateProvider, $urlRouterProvider, routeResolverProvider, $controllerProvider,
              $compileProvider, $filterProvider, $provide, $httpProvider, 
              dashboardResolverProvider, dialogsProvider, localStorageServiceProvider, ROUTER, $translateProvider) {

        dialogsProvider.useBackdrop(true);
        dialogsProvider.useEscClose(true);
        dialogsProvider.useCopy(false);
        dialogsProvider.setSize("sm"); 

构建webpack包之后,我打开了Web浏览器并在控制台中看到了这个错误: TypeError: Cannot read property 'useBackdrop' of undefined

显然,dialogsProvider没有注入。如何注射?

app.js

import './app.module';
import './app.config';
import './app.run';
import './controllers/FirstController'
import './directives/FirstDirective'
...
angular.bootstrap(document, ['hepicApp']);

app.module.js

import 'angular';
...
import 'angular-dialog-service';
...
var app = angular.module('hepicApp', [
  'dialogs.main',
  ...
]);
export default app;

1 个答案:

答案 0 :(得分:1)

试试这样。

app.config(['$stateProvider', '$urlRouterProvider', 'routeResolverProvider', '$controllerProvider','$compileProvider', '$filterProvider', '$provide', '$httpProvider',
        'dashboardResolverProvider','dialogsProvider', 'localStorageServiceProvider','ROUTER',
        '$translateProvider',

function ($stateProvider, $urlRouterProvider, routeResolverProvider, $controllerProvider,
          $compileProvider, $filterProvider, $provide, $httpProvider, 
          dashboardResolverProvider, dialogsProvider, localStorageServiceProvider, ROUTER, $translateProvider)

永远记住,这里的依赖顺序最重要。