In the angularjs single page application project that I'm working on, there are two modules: module-'A'
and module-'B'
. Each module has its own view templates.
The view template of module-'B'
contains a div with id="siteDataView"
, which I need to hide from the controller function named hideMenu()
in module-'A'
.
I attempted to achieve this by writing the following code:
(function () {
"use strict";
angular.module("module-A").controller("module-A-Controller", ["$state", module-A-Controller]);
function module-A-Controller() {
var self = this;
this.hideMenu = function () {
var elem = document.getElementById("siteDataView");
elem.hide();
}
self.hideMenu();
}
})();
However, I encountered an issue where the elem
variable is always null.
Do you have any insights on what I might be missing? Why am I unable to access the element with id=siteDataView
?