Okay so I have two controllers that control two distinctly different parts of the site, that are on the same page.
The first is for a newsletter signup form, the second is for a basket. The second is not directly placed in the DOM as an ng-controller directive, but instead as a controller for a custom directive.
Some code:
<div ng-controller="newsletter-signup">
<div ng-show="showLoader">
... Cool loading animation here ...
</div>
... Form in here ...
</div>
<div basket>
<div ng-show="showLoader">
... Cool loading animation here ...
</div>
... Basket data in here ...
</div>
The problem that I am having is that both of these contain a div that I only want to show under certain conditions, and this div is stored in a template file:
<div ng-show="showLoader">
... Cool loading animation here ...
</div>
This however get's shown on both the newsletter and basket when $scope.showLoader is true in either of the controllers.
I can't seem to figure out how to isolate the scopes from each other, but continue to use the same variable name.
The basket directive looks like this:
return {
link : linkFn,
scope: '=',
restrict : 'A',
controller : 'BasketController'
};
BasketController is never defined in the template.
How can I get to a resolution with this?
I don't want the div for the newsletter to show when the basket is being updated, and likewise, I don't want the div for the basket to show when the newsletter is being updated.
EDIT: We are using the following to define components, I am wondering if this is the root cause.
window.angular.module('Basket', []);
window.angular.module('App', ['Basket']);
scope: {}to create an isolated scope. But does the basket directive have a template? I just don't understand what it does based on what you posted.divof some dynamic content. It doesn't have it's own template. I'll update to be clearer.divs parent won't ever contain theshowLoader, and it also doesn't have it's own scope. I am trying to isolate the two from each other.