angularjs中的判断语句说明:
由于angularjs不支持if-else结构,所以判断的写法如下:
1、用三目运算符:
<span>{{isLarge ? 'video.large' : 'video.small'}}</span>
2、使用ng-switch结构
<div ng-switch on="video">
<div ng-switch-when="video.large">
</div>
<div ng-switch-default>
<!-- code to render the regular video block -->
</div>
</div>
3、使用ng-if(angularjs 1.1.5以后版本有效):
<div ng-if="video == video.large">
<!-- code to render a large video block-->
</div>
<div ng-if="video != video.large">
<!-- code to render the regular video block -->
</div>
网友评论