Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9237471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:32:33+00:00 2026-06-18T07:32:33+00:00

In my previous question I got an answer hot to inject dependencies and while

  • 0

In my previous question I got an answer hot to inject dependencies and while I tested it, everything worked well. Then I refactored the code and wanted to start the app implementation, but the injections stopped to work 🙁
http://jsbin.com/alemik/1/edit

In addittion to jsbin, here is the source:

var ABCS = angular.module("ABCS", []);
ABCS.Configuration = angular.module('ABCS.Configuration', []);
ABCS.Controllers = angular.module('ABCS.Controllers', []);
ABCS.Modules = angular.module("ABCS.Modules", []);
ABCS.Services = angular.module("ABCS.Services", []);

ABCS.run(["$rootScope", "$location", "ABCS.Services.LogService",
         function ($rootScope, $location, logger) {
             logger.log("app start");
         }]);

ABCS.Configuration.factory("Environment", function () {
    return {
        logOutputElementId: "output",
        hasConsole: console && console.log
    }
});

//Log service
ABCS.Services.LogService = function (config) {
    this.log = function (message) {
        if (typeof (config.Environment.logOutputElementId) === "string") {
            document.getElementById(config.Environment.logOutputElementId).innerHTML += message + "<br/>";
        }
        else if (config.Environment.hasConsole) {
            console.log(message);
        }
        else {
            alert(message);
        }
    };
};
ABCS.Services.LogService.$inject = ["ABCS.Configuration"];
ABCS.Services.factory("ABCS.Services.LogService", ABCS.Services.LogService);

What I miss? Why ABCS.Services.LogService can not be injected in current structure.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:32:34+00:00Added an answer on June 18, 2026 at 7:32 am

    In my opinion , that’s the angularJS way of doing things ( though i kept all the DI definitions ):

    angular.module("ABCS", ['ABCS.Services', 'ABCS.Configuration', 'ABCS.Controllers', 'ABCS.Modules', 'ABCS.Services']);
    angular.module('ABCS.Configuration', []);
    angular.module('ABCS.Controllers', []);
    angular.module("ABCS.Modules", []);
    angular.module("ABCS.Services", []);
    
    angular.module("ABCS").run(["$rootScope", "$location", "ABCS.Services.LogService",
             function ($rootScope, $location, logger) {
                 logger.log("app start");
             }]);
    
    angular.module('ABCS.Configuration').factory("ABCS.Configuration.Environment", function () {
        return {
            logOutputElementId: "output",
            hasConsole: console && console.log
        };
    });
    
    angular.module("ABCS.Services").factory("ABCS.Services.LogService",["ABCS.Configuration.Environment",function (environment) {
      function LogService() {
        this.log = function (message) {
            if (typeof (environment.logOutputElementId) === "string") {
                document.getElementById(environment.logOutputElementId).innerHTML += message + "<br/>";
            }
            else if (environment.hasConsole) {
                console.log(message);
            }
            else {
                alert(message);
            }
        }
      }
    
      return new LogService();
    }]);
    

    angularJS allows to reopen a module definition in multiple files , and javascript namespacing is totally unecessary unless the object is not tight to the angularJS application.

    Mixing javascript namespacing and DI namespacing makes code more error prone ,not more maintanable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got the below code from an answer on a previous question here .
I am using LongIntParallelHashMultimap java code which I got as my previous question's answer
This question is based on my previous question which I got a working answer
This is a CSS related question, I got one good answer from my previous
In a previous question I got an answer for downloading an artifact from the
In my previous question I got an excellent answer that helped me detect where
Just got this answer from a previous question and it works a treat! SELECT
This is a follow up to a previous question; I got an answer I
In a previous question of mine I got the following answer, which is perfect,
This question is related to my previous question where I got answer to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.