0

An unknown provider error of var "frameworks" appears in resolve, what is wrong? thanks! FrameworkService.loadFrameworks() return a JSON array from REST Service.

app.js

$routeProvider.when('/', {
    templateUrl : "views/admin.html",
    controller : "FrameworkController",
     resolve : {
        frameworks : function(FrameworkService) {
            return FrameworkService.loadFrameworks();
        }
    }
});

FrameworkController.js

angular.module('app.controllers', []).controller(
    'FrameworkController',
    [ '$scope', 'FrameworkService', 'frameworks',
            function($scope, frameworks) {
                $scope.frameworks = frameworks;
            } ]);

ERROR

Error: [$injector:unpr] Unknown provider: frameworksProvider <- frameworks

EDIT

The code showed here it's ok! The problem was in the FrameworkService, that do an asynchronous http request, so var frameworks wasn't injected.

2
  • your controller function signature should be with all the parameters defined in inline definition: $scope, FrameworkService, frameworks. In your case I think you could delete FrameworkService inline definition Commented May 10, 2014 at 14:33
  • I removed FrameworkService of the definition but the same error appears. thanks anyway Commented May 11, 2014 at 18:23

1 Answer 1

1

You don't have a frameworks provider in your module, so the injector can't give you one. You need to create one be it a service, factory, etc. Depending on what you want.

Sign up to request clarification or add additional context in comments.

1 Comment

I thought that "frameworks" var was injected in the controller automatically. I saw that in one tutorial.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.