0

I am using ng-repeat to display all the JSON data in list. However, I each of the data, some data consist of text data and some consist of image data. If it consist of image data, it will display of image and if it consist of text data, application is displaying text data. I am using ng-if condition to display either text data or image data. The following is my code.

html

        <li ng-repeat="message in messages"  ng-class="getClass(message.username)">
                     <div class="avatar"><img ng-src="{{image}}"  
draggable="false"/></div>
                     <div class="msg">
                        <img ng-if="{{message.messageType}} =='image'" ng-src="img/adam.jpg"></img>
                        <p ng-if=" {{message.messageType}} =='text'">{{message.content}}</p>
                        <time>{{ message.date | date:"MM/dd/yyyy 'at' h:mma"}}<time>
                    </div>
            </li>

1 Answer 1

1

Just remove the expression {{}},

   <img ng-if="message.messageType =='image'" ng-src="img/adam.jpg"></img>
   <p ng-if="message.messageType =='text'">{{message.content}}</p>
Sign up to request clarification or add additional context in comments.

4 Comments

can you explain more about {{}} in angularjs?
please accept the answer if it had solved your issues
@Sajeetharan Thanks, it very helpful for me.

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.