0

I'm trying to inject datepickerConfig inside the run phase, but angular says that it's unable to find the provider: Unknown provider: datepickerConfigProvider <- datepickerConfig.

this is the code:

(function () {
     angular.module('app', ['ngAnimate', 'ngCookies', 'ngRoute', 'ngSanitize', 'pascalprecht.translate', 'ui.bootstrap', 'ui.select']);

     // config phase is omitted, it only configures the i18n async loading

     function runFn($translate, datepickerConfig) {

         datepickerConfig.currentText = $translate('label.today');
         datepickerConfig.clearText = $translate('label.clear');
         datepickerConfig.closeText = $translate('label.close');

     }

     runFn.$inject('$translate', 'datepickerConfig');

     angular.module('app').run(runFn);
})();

I also tried to inject datepickerConfig inside the config phase, but angular gave me the same error.

I really can't figure out what is the problem.

In the index.html i have all the .js I need

<script type="text/javascript" src="bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="bower_components/angular/angular.min.js"></script>
<script type="text/javascript" src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
<script type="text/javascript" src="scripts/app.js"></script>

what's wrong?

Thanks

Arcangelo V.
  • 41
  • 1
  • 8
  • 3
    Older versions of ui-bootstrap put "uib" before the name of diretives - uibDatepicker, uibDatepickerConfig. Or maybe it's newer ones. I recommend looking through the non-minified js file to see what the `.constant()` and `.factory()` calls actually use for a name. – Dave Feb 22 '16 at 17:18
  • Thanks, I was using a snippet for ui-bootstrap 0.12.1 (Angular 1.2.8) in ui-bootstrap 1.12.1 (Angular 1.4.9) so the problem was that in 1.12.1 it uses the uib prefix. – Arcangelo V. Feb 25 '16 at 10:18
  • May I ask what solution was applied ? – Stephane Mar 18 '17 at 19:27
  • I replaced all `datepickerPopupConfig` instances by `uibDatepickerPopupConfig` and all `datepickerConfig` ones by `uibDatepickerConfig` and the issue was gone. Indeed, my `bower_components/angular-bootstrap/ui-bootstrap.js` dependency file was showing usage of the `uib` prefix. – Stephane Mar 18 '17 at 19:33

0 Answers0