It is unclear for me what you need to achieve, but maybe it will be useful:
function Controller (SomeService) {
var vm = this;
vm.firstVisible = false;
vm.secondVisible = false;
SomeService.getData().then(data) {
// firstValidation() function returns true if first way of display is matching
if (firstValidation(data)) {
vm.firstVisible = true;
}
// secondValidation() function returns true if second way of display is matching
if (secondValidation(data)) {
vm.secondVisible = true;
}
}
}
And then in HTML:
<div>
<div ng-if="vm.firstVisible">
First way of displaying data
</div>
<div ng-if="vm.secondVisible">
Second way of displaying data
</div>
</div>
(Intentionally I don't use $onInit
or other stuff to do not make things complicated)
ng-if
/ng-show
itself..?? your question seems unclear – Pankaj Parkar yesterdayng-if="foobar"
wherefoobar
is a property on your scope that you change based on the logic you need. – Kevin B yesterday