Andrew Gray
Andrew Gray

Reputation: 3790

Using a service in app.config

So, I'm continuing my self-education in Angular...and, I've written yet more code that dosen't work, and I don't know why!

Failing Fiddle

For this go-round, I'm writing a small front-end that I'm using to learn the Angular UI for Bootstrap datepicker system inside and out. However, you'll notice that my two datepickers simply aren't working!

I strongly suspect that, among my problems, is how I'm invoking the app.services.Enum object in the app.config, to configure a default filter function for which days are selectable. Pretty much, by default I'm trying to disable Sunday from being selectable, but the more specific case disables both Saturday and Sunday.

Question: How do I properly use my service in app.config? What's more, what else am I doing wrong?

Upvotes: 0

Views: 51

Answers (1)

Anthony Chu
Anthony Chu

Reputation: 37520

You can't inject services in a config block. Try changing Enums to be a constant instead.

appServices.constant('Enums', {
    DaysOfTheWeek : {
            "Sunday": 0,
            "Monday": 1,
            "Tuesday": 2,
            "Wednesday": 3,
            "Thursday": 4,
            "Friday": 5,
            "Saturday": 6
        },
    PickerMode : {
            Day: "day",
            Year: "year",
            Month: "month"
        }
});

Upvotes: 1

Related Questions