2016-07-29 15 views
1

で返されていないとき、私は私の角度アプリで次のHTMLを持っている:Types非表示と表示要素はデータが角度

内のすべての項目を表示し、その仕事は、今、私はに

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

上記をしたいんTypesに要素がない場合は、テキストボックスとボタンを表示します。これを行う最善の方法は何でしょうか?

答えて

4

あなたはこれを試すことができます。

<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> 
+1

はとてもうまくいきました。ありがとうございました! – ElenaDBA

1
<div class="row" ng-show="Types"> 
     <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> 

<div ng-show="!Types">Button and Textbox go here</div> 

または

<div ng-show="Types == null"> Button and textbox go here</div> 
関連する問題