2014-09-05 16 views
11

Pracuję nad złożoną aplikacją, w której muszę wyłączyć łącze, jeśli identyfikator wysłany z backendu spełnia określone kryteria. Używam tego teraz, ale nie wiem, czy to jest poprawne:AngularJS ng-show potrójne warunkowe z wieloma warunkami

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

Czy to wygląda prawda?

Odpowiedz

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

Dlaczego nie przenieść tę logikę do kontrolera więc trzeba

html:

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

kontroler:

$scope.showParentheader = function(id) { 
    return ! (id === '807' || id ==='806' || id ==='808'); 
} 
2

można zrobić tak:

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

czyli

ng-show=" !(parentheaderData.casid === '807' || parentheaderData.casid ==='806' parentheaderData.casid === || '808')" 
9

Dzięki za wszelką pomoc. Prawidłowe rozwiązanie to:

ng-hide="parentheaderData.casid == '806' || parentheaderData.casid == '807' || parentheaderData.casid == '808'" 
+0

Powinieneś przyjąć tę odpowiedź jako poprawną – Icet

Powiązane problemy