1

I have the following html in my Angular app:

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

The above does its job displaying all the items in Types

Now I want to display a textbox and a button whenever there are no elements in Types. What would be the best way to do this?

2 Answers 2

4

You can try this:

<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>
Sign up to request clarification or add additional context in comments.

Comments

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>

or

<div ng-show="Types == null"> Button and textbox go here</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.