AngularJS根据布尔值打印是或否

Arj*_*jun 4 angularjs

我从数据库到angularJs得到Bool值

<td>
    {{patient.Alcoholic}}
</td>
Run Code Online (Sandbox Code Playgroud)

而不是假或我需要打印是或否

<td>
    {{patient.Alcoholic // can i have if-else condition over here ??}}
</td>
Run Code Online (Sandbox Code Playgroud)

小智 13

<td>
 {{true == patient.Alcoholic ? 'Yes' : 'No' }}
</td>
Run Code Online (Sandbox Code Playgroud)

这应该工作!

  • 只需使用`{{patient.Alcoholic?'是':'不'}}` (13认同)

Sud*_*n S 10

使用ng-if指令

 <td ng-if="patient.Alcoholic">Yes</td>
 <td ng-if="!patient.Alcoholic">NO</td>
Run Code Online (Sandbox Code Playgroud)