如果没有属性值,则AngularJS条件显示

时间:2015-09-09 11:17:55

标签: angularjs conditional

我是AngularJS的新手,我想创建一个条件显示,如果我的系统中的文件没有属性,它将显示“此文件没有属性”

我的html目前是这样的:

<div>
    <br />                 
    <ul class="list-unstyled">
        <li ng-repeat="fileInfo in fileResources">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <span class="label label-default">{{fileInfo.DocType}}</span>
                    <span class="panel-title">{{fileInfo.Name}}</span>
                </div>
                <div class="panel-body">
                    <div class="panel panel-info" ng-if="fileInfo.fileAttributes">
                        <div class="panel-heading">file Attributes</div>
                        <div class="panel-body">
                        <ac-file-attributes
                            file-attributes="fileInfo.fileAttributes"
                            display-options="displayOptions">
                        </ac-file-attributes>
                        </div>
                    </div>

                    <div class="panel panel-info" ng-if="fileInfo.PhysicalProperties" >
                        <div class="panel-heading">Physical Properties</div>
                        <div class="panel-body">
                            <ac-physical-properties
                                phys-props="fileInfo.PhysicalProperties" 
                                display-options="displayOptions">
                            </ac-physical-properties>
                        </div>
                    </div>
                </div>

            </div>

        </li>
    </ul>
</div>

1 个答案:

答案 0 :(得分:1)

如果上述代码已经有效,则可以使用以下代码,这些代码只是“不是&#39; nots&#39; fileInfo.fileAttributes

<div class="panel panel-info" ng-if="!fileInfo.fileAttributes">
                    <div class="panel-heading">file Attributes</div>
                    <div class="panel-body">
                    <ac-file-attributes
                        file-attributes="fileInfo.fileAttributes"
                        display-options="displayOptions">
                    </ac-file-attributes>
                    </div>