我有一個很長的一行if語句在ng中 - 如果在我的html中。它太長了,所以我想做一個函數來評估它。如何返回AND和OR邏輯運算符JavaScript
我的問題是,我不能讓我圍繞着如何「轉換」的& &或頭||嵌套if語句,我可以在一個函數中。能有人比我更聰明一些,能幫助我嗎?
這是我要轉換爲嵌套的if語句邏輯(我縮進它讓我在做什麼):
ng-if="(
(
(filter === 'critical')
||
(
!(
(filter === 'status')
||
(filter === 'events')
)
&&
(
(
!(door.status_error_array.length >= 1)
&&
(door.event_array.length >= 1)
)
||
(
!(door.status_error_array.length >= 1)
&&
!(door.event_array.length >= 1)
)
)
)
)
&&
(door.critical_error_array.length >= 1)
)"
我不明白你的意思 - 如果你有邏輯的工作,爲什麼不能你只需動動手,爲一個函數模型? – Jamiec
我不知道該怎麼做......我不認爲我可以這樣寫嗎?我認爲我需要用if語句來編寫它?不是嗎? – pandaseal
@pandaseal'if(/ * current contents * /)'? –