Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当Angular未返回任何数据时隐藏和显示元素_Javascript_Html_Angularjs_Angularjs Ng Repeat - Fatal编程技术网

Javascript 当Angular未返回任何数据时隐藏和显示元素

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

我的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 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>