0

I'm trying to access a variable from Module-1 inside Module-2... how will I do that?

Example: Module 1

(function () {
    'use strict';

    angular.module('app.Mod1')
        .component('topHeading', {
            templateUrl: 'someTemplate.template.html',
            controller: FirstController,
            controllerAs: 'first'
        });

    function FirstController() {
        /* jshint validthis */
        let vm = this;

        vm.search = 'Sample...';

    }

})();

Example: Module 2

(function () {
    'use strict';

    angular.module('app.Mod2')
        .component('tabSection', {
            templateUrl: 'someTemplate.template.html',
            controller: SecondController,
            controllerAs: 'second'
        });

    function SecondController() {
        /* jshint validthis */
        let vm = this;

        //I WANT TO ACCESS/ASSIGN app.Mod1 vm.search HERE
        vm.search = 'Sample...';

    }

})();

Based on the given code above how will I bind the variable vm.search of "app.Mod1" to "app.Mod2" ???

The scenario is that I have created separate Module for the HEADER and I want to access its variables from another Module and my goal is to do a Two-Way Binding from within another Module... is that possible?

Emz
  • 482
  • 1
  • 3
  • 10

0 Answers0