1

I'm trying to set up some constants for an Angular config through a provider, but for some reason I can't see, I keep getting the error:

Unknown provider: myprovider

I have plenty of dependency injection throughout my project, but I can't figure out why this one will not work.

The order of the code below is the same order as in my config.js.

Provider

var trybConfig = angular.module('trybConfig', []);

trybConfig.provider('myprovider', function() {
this.Routes = {
    EventList: {
        Location: "/Event",
        Template: "views/eventView.html",
        Controller: "eventController"
    }
}
this.$get = function () {
    return this.Routes;
}
});

Config

trybConfig.config(function($routeProvider, myprovider) {

$routeProvider
    .when('/Event', {
        templateUrl: 'views/eventView.html',
        controller: 'eventController'
    })
    .otherwise({
        redirectTo: '/Event'
    });
});

1 Answer 1

2

Don't add "provider" to the name of your service prodiver, just do:

trybConfig.provider('my', function() {

And inject it:

trybConfig.config(function($routeProvider, myProvider) {

FYI - In your current state you need to inject:

trybConfig.config(function($routeProvider, myproviderProvider) {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.