Angular - Unknown vendor from vendor

I have a weird problem that somehow my own provider is incorrectly typing into my application.

This is my provider:

    angular.module '1425App'
    .provider 'OData',[() ->
      @_baseUrl = ''
      return {
        setBaseUrl: (value) ->
          @_baseUrl = value
          return
        $get: ['$http', '$q', ($http, $q) ->
          return {
          getAll: (resource) ->
            dfd = $q.defer()
            $http.get("#{@_baseUrl}/#{resource}").success (res) ->
              console.log res
              dfd.resolve()
              return
            return dfd.promise
          }
        ]
      }
    ]

      

This is my app + config block:

angular.module('1425App', [
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ui.router',
  'angular-loading-bar',
  'ngAnimate',
  'toaster',
  'ui.gravatar',
  'ngFitText',
  'google-maps',
  'mm.foundation',
  'restangular',
  'ui.select2',
  'ngTable',
  'ngGrid',
  'ngCsv',
  'ui.date',
  'ngDragDrop',
  'ui.sortable'
])
.config ($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider, cfpLoadingBarProvider, baseUrl, ODataProvider) ->
  $httpProvider.interceptors.push('httpInterceptor')

  ODataProvider.setBaseUrl(baseUrl + '/odata/')
  cfpLoadingBarProvider.includeSpinner = false
...

      

I'm getting the following error:

Unprepared error: [$ injector: modulerr] Failed to instantiate module 1425App due to: Error: [$ injector: unpr] Unknown provider: ODataProvider

This leads to what I believe to be a problem with injecting the provider into my application. Any idea what they are missing?

+3


source to share


1 answer


Looking at what you've inserted the snippets issue, it might be that you have a config block popping up before the provider was registered oData

. Try adjusting the config block after registering oDataProvider.

Separate the config block from the app registration and load it after registering your provider (s). You can configure vendors that are registered before a specific config block that uses it. This is not the case constant

, although you can register them in any order.



The above information (which was a bug) is of version 1.2. * angular version, since 1.3 you can register providers even after config block.

+2


source







All Articles