I am new to learning AngularJS, so this question might feel wrong, but I would like to know the correct way atleast.
I am creating an html page where the header and footer part I need to keep same. So, I created a header.html and footer.html and added them to my index.html using ng-include directive of AngularJS.
Now, in my header.html I have a text which displays some hidden content when clicked on it. So, I am using ng-click for this. This works fine if I load the header.html file directly.
But, since it is meant to be a part of index.html, when I try to click on the same text through loading index.html, the ng-click doesnt work.
I know there is some problem with scope. But, I dont understand why this is not working.
The ng-app and ng-controller are different for header and index files.
Let me know if you need any more details.
Edit:
Relevant Code Snippets:
header.html
<body ng-app="headerCode" ng-controller="headerCtrl">
<div id="popup">Hello</div>
<p id="myaccount" ng-click="showLoginUI()">Sign in / My Account</p>
<script>
var app = angular.module('headerCode', []);
app.controller('headerCtrl', function($scope) {
$scope.showLoginUI = function() {
document.findElementById('popup').style.display = "block";
}
}
</script>
</body>
index.html
<body ng-app="">
<div id="header" ng-include="'header.html'">
</div>
</body>