I'm using Angular 1.6.7. I have created multiple modules in my app. How can I pass a constant (e.g. "rootURL") defined in a parent module (myApp) to a child module (childApp)? More specifically, I need to assign the value of "rootURL" to the templateUrl of childApp's component so we don't have to hard code the root directory for every module. I think I know how to share variables inside a controller, but don't know how to do that inside the definition of a component.
Here's a Plunker to demo. In app.module.js I defined a constant "config". What can I do so that when I define the component for "child" (components/child.component.js), instead of templateUrl: "components/child.html", I can say something like "config.rootURL + child.html"? We do not have to use constant.
Thank you in advance.
// app.module.js
(function(){
    "use strict";
    var myApp = angular
        .module("myApp", ["child"]);
    myApp.constant("config", {
        rootURL: "components/"
        , version: "myApp1.0.0"
    })
})();
// app.component.js
(function(){
    "use strict";
    // Define controller
    function mainController(){
        this.$onInit = function() {
            var mainVM = this;
            mainVM.parent = {
                "lastName": "Smith"
                , "firstName": "Jordan"
            };
        };
    }
    // Define component
    var mainComponent = {
        controller: mainController
        , controllerAs: "mainVM"
    };
    // Register controller and component
    angular.module("myApp")
        .controller("mainController", mainController)
        .component("mainComponent", mainComponent);
})();
// components/child.module.js
(function(){
    "use strict";
    var child = angular.module("child", []);
})();
// components/child.component.js
(function(){
    "use strict";
    // Define controller
    function childController() {
        this.$onInit = function() {
            var vm = this;
            vm.child = {
              "firstName": "Jack"
            }
        };
        // end of $onInit()
    }
    // Define component
    var child = {
        templateUrl: "components/child.html"
        , controller: childController
        , controllerAs: "vm"
        , bindings: {
            parent: "<"
        }
    };
    // Register controller and component
    angular.module("child")
        .controller("childController", childController)
        .component("child", child);
})();<!DOCTYPE html>
<html>
  <head>
    <script src="//code.angularjs.org/snapshot/angular.js"></script>
    <link rel="stylesheet" href="style.css">
    <script src="app.module.js"></script>
    <script src="app.component.js"></script>
    <script src="components/child.module.js"></script>
    <script src="components/child.component.js"></script>
  </head>
  <body ng-app="myApp" ng-controller="mainController as mainVM">
    Parent: {{mainVM.parent.firstName}} {{mainVM.parent.lastName}}<br>
    <child parent="mainVM.parent"></child>
  </body>
</html>
<!-- components/child.html -->
Child: {{vm.child.firstName}} {{vm.parent.lastName}} 
     
    