角度跨度条件悬停在文本上

时间:2017-07-12 08:40:14

标签: javascript html angularjs button controller

我从后端得到3个值:isDone,isInProgress,isFailed,基于这3个值,我需要在angularview中更改悬停在span元素的文本上。如果元素是isDone或isInProgress,我必须显示一个带有2个不同悬停文本的图标。如果元素是isFailed,我必须在屏幕上显示错误消息:

代码:

<span class="glyphicon glyphicon-refresh blue"                                                      
 title="In progress" ng-show="action.isInProgress"> </span>

如何在这个范围内加入IsDone?

3 个答案:

答案 0 :(得分:6)

这样做:

<span class="glyphicon glyphicon-refresh blue" title="{{ action.isInProgress ? 'Action is in progress' : 'Action is complete.'}}" ng-show="action.isInProgress||action.isDone"></span>

答案 1 :(得分:2)

您可以使用条件检查

<span class="glyphicon glyphicon-refresh blue"                                                      
     title=" Action is Complete" ng-if="action.isDone"> </span>

<span class="glyphicon glyphicon-refresh blue"                                                      
     title="Action in progress" ng-if="action.isInProgress"> </span>

答案 2 :(得分:2)

怎么样

<span class="glyphicon glyphicon-refresh blue"                                                      
 title="{{status}}" > </span>

并根据值status

更新您的"In progress", or ..变量