Javascript 当Angular未返回任何数据时隐藏和显示元素
我的Angular应用程序中有以下html:Javascript 当Angular未返回任何数据时隐藏和显示元素,javascript,html,angularjs,angularjs-ng-repeat,Javascript,Html,Angularjs,Angularjs Ng Repeat,我的Angular应用程序中有以下html: <div class="row"> <div ng-repeat="Type in Types"> <div class="col s12 m6 l3"> <div class="class1" ng-click="Method1(Type.Id, Type.Desc)"> <div c
<div class="row">
<div ng-repeat="Type in Types">
<div class="col s12 m6 l3">
<div class="class1" ng-click="Method1(Type.Id, Type.Desc)">
<div class="white-text">
<img id="img_{{Type.Id}}" ng-src="./Images/{{Type.Desc}}" alt="{{Type.Desc}}" />
<h3>{{Type.Desc}}</h3>
</div>
</div>
</div>
</div>
</div>
{{Type.Desc}}
上面的工作是显示类型中的所有项目
现在,每当类型中没有元素时,我想显示一个文本框和一个按钮。最好的方法是什么?您可以尝试以下方法:
<div class="row">
<div ng-if=" Types == null || Types.length == 0">
<!-- Your textbox / input button here-->
</div>
<div ng-repeat="Type in Types">
<div class="col s12 m6 l3">
<div class="class1" ng-click="Method1(Type.Id, Type.Desc)">
<div class="white-text">
<img id="img_{{Type.Id}}" ng-src="./Images/{{Type.Desc}}" alt="{{Type.Desc}}" />
<h3>{{Type.Desc}}</h3>
</div>
</div>
</div>
</div>
</div>
{{Type.Desc}}
您可以尝试以下方法:
<div class="row">
<div ng-if=" Types == null || Types.length == 0">
<!-- Your textbox / input button here-->
</div>
<div ng-repeat="Type in Types">
<div class="col s12 m6 l3">
<div class="class1" ng-click="Method1(Type.Id, Type.Desc)">
<div class="white-text">
<img id="img_{{Type.Id}}" ng-src="./Images/{{Type.Desc}}" alt="{{Type.Desc}}" />
<h3>{{Type.Desc}}</h3>
</div>
</div>
</div>
</div>
</div>
{{Type.Desc}}
{{Type.Desc}}
按钮和文本框转到这里
或
按钮和文本框转到此处
{{Type.Desc}}
按钮和文本框转到这里
或
按钮和文本框转到此处
<div ng-show="Types == null"> Button and textbox go here</div>