This is a relatively simple question but I cannot figure out why this isn't working.
So I have ng-if statement in HTML where I check condition if its not true. as in:
<div class="new-asset" data-ng-if="$root.questionData.question_type_id != '1' || $root.questionData.question_type_id != '8'">
But for some reason this does not work. I also tried:
<div class="new-asset" data-ng-if="($root.questionData.question_type_id != '1' || $root.questionData.question_type_id != '8')">
Which has no affect whatsoever... I was reading up and trying to find a solution, someone suggested placing the condition in controller, which would also have performance increase (not 100% sure if it would), as in:
$scope.addNewAssetIf = $root.questionData.question_type_id != '1' || $root.questionData.question_type_id != '8';
and then referencing it in html as:
<div class="new-asset" data-ng-if="addNewAssetIf">
But I cannot use this approach due to asynchronous loading, and dependencies. I need to make this work somehow, I get no errors or anything, even though the question_type_id is 1 I still get .net-asset div shown. If I remove OR statement and only have 1 condition it works:
<div class="new-asset" data-ng-if="$root.questionData.question_type_id != '1' || $root.questionData.question_type_id != '8'">
Any help is appreciated.
Thanks
I'm ignoring everything angular related and trying to understand the basic logic behind the condition. If the ID == 1 won't it satisfy the second condition which asks it to be different from 8? And isn't that true for cases where the ID is 8?
In other words, don't you need && instead of ||?
This should really be a comment but I don't have enough reputation.