0

I'm trying to resolve a promise before instantiate a route in angularjs but I'm getting Unknown provider error and I don't know why, I have basically the exact same code in another app.

The error is: Error: [$injector:unpr] Unknown provider: userProvider <- user

Here is my config:

$routeProvider.when('/', {
        redirectTo: '/main'
    }).when('/main', {
        controller: 'MainController',
        templateUrl: 'app/wiki/partials/MainView.html',
        resolve: {
            user: function($http) {
                return routeController.accessLevel($http, 0);
            }
        }
    })

var routeController = app.controller('routeController', ['$scope', function($scope) {

}]);

routeController.accessLevel = function($http, access) {    

    return $http({
        method: 'POST',
        url: "/users/auth/" + access,
        headers: {'Content-Type': 'application/x-www-form-urlencoded'}
    }).success(function(data, status, headers) {
        return data;
    }).error(function(data, status, headers) {
        if(status == 401) {
            window.location.replace('/');
        }
    });


};

angular.module('WikiApp.Controllers.MainController', [])
    .controller('MainController', ['$scope', '$location', '$anchorScroll','user', function ($scope, $location, $anchorScroll, user) {}])

1 Answer 1

2

This is just my guess, you might also have an ng-controller="MainController" set in the template MainView.html.

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

2 Comments

NVM, it was being instantiated in a parent view... :P
Have you looked in the main template, may be index.html?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.