I would like to use angular to show/hide or remove a parent div, dependant on the contents of a child div.
<div id="display-wrapper">
<div class="display-title">{{SELECTION.TITLE}}</div>
<div class="display-text">{{selection.text|| SELECTION.NO_TEXT}}</div>
</div>
Depending on what the user has selected in a search window the div will be populated with data. Sometimes there will be no data for these particular divs. I am happy to use ngShow or ngIf as it won't affect display or logic. So if the child div display-text is empty, I want the parent div to be removed or hidden.
I have tried capturing innerHTML or innerText and while I can do it for the parent div, I cannot get the parent div to operate based on the contents of the child.
Addition after suggestion.
Is it possible my site is interfering? If I try the following on jsfiddle it behaves as I want.
<div id="display-wrapper" ng-show='{{selection.text}}'>
<div class="display-title">{{SELECTION.TITLE}}</div>
<div class="display-text">{{selection.text|| SELECTION.NO_TEXT}}</div>
</div>
essentially if there is a value assigned to selection.text the div shows, if either selection.text is not assigned or is assigned the empty string, the div does not show.
When I try this on the site I get the following code generated.
(1) When selection.text = "I should be visible"
<div id="display-wrapper" ng-show="I should be visible" style="display: none;">
<div class="display-title ng-binding">
TITLE
</div>
<div class="display-text" ng-binding">
I should be visible
</div>
</div>
(2) When selection.text = ""
<div id="display-wrapper" ng-show="" style="display: none;">
<div class="display-title ng-binding">
TITLE
</div>
<div class="display-text" ng-binding">
no user data
</div>
</div>
(2) is doing what it should do and not displaying, (1) should display as ng-show="I should be visible" but the code has generated a style="display: none;"
Any help please?
ng-show='{{selection.text||SELECTION.NO_TEXT||SELECTION.TITLE}}'does not work? (if this gets too complex, move the condition to the controllerng-show='sectionIsEmpty()'or modelng-show='sectionIsEmpty')ng-show='selection.text||SELECTION.NO_TEXT'(without the braces).