我正在将json数据渲染到html页面:
Status :{{task_detail.status}}
这是我渲染的json数据:
{ "id": 1, "title": "Launch an EC Instance", "desc": "Needed an EC instance to deploy the ccr code", "status": "done", "percentage_finished": 100 }
问题:HTML视图不可见,因为控件没有移动到内部ng-if
.语法是否正确?
ngIf
接受表达式(类似JavaScript的代码片段).这意味着在它之间写的任何东西" "
已经在Angular的上下文中,你不需要使用{{ }}
:
<div ng-if="task_detail.status == 'done'">
ngIf也接受功能.
<div ng-if="checkStatus(task_detail.status)">
当您有多个代码或添加逻辑来定义ng-if中的布尔结果时,这非常有用.我经常使用它.