Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS ng-show ternary conditional with multiple conditions

Tags:

angularjs

Im working on a complex app where I need to disable a link if the ID sent from backend meets a certain criteria. I'm using this now but not sure if it is correct:

ng-show="parentheaderData.casid === '807' || '806' || '808' ?false:true"

Does this look right?

like image 540
jmccommas Avatar asked Sep 05 '14 15:09

jmccommas


2 Answers

Why don't you move this logic to a controller so you have

html :

ng-show="showParentheader(parentheaderData.casid)"

controller:

 $scope.showParentheader = function(id) {
     return  ! (id === '807' || id ==='806' || id ==='808');
 }
like image 151
MiTa Avatar answered Oct 20 '22 01:10

MiTa


Thanks for all the support. The correct solution was:

ng-hide="parentheaderData.casid == '806' || parentheaderData.casid == '807' || parentheaderData.casid == '808'"
like image 10
jmccommas Avatar answered Oct 20 '22 00:10

jmccommas