user2816085 user2816085 - 12 days ago 5
AngularJS Question

Angular, ng-repeat not working in same paragraph

I am trying to use

ng-repeat
inside a paragraph
<p>
tag. But it is not working.
Below is my code:

<div class="section">
<p class="text-left">
<strong>Designation:</strong>{{showData.Designation}}&nbsp;&nbsp;
<strong>Company:</strong> &nbsp;{{showData.Company}}&nbsp;&nbsp;
<b ng-repeat="location in showData.City">Location:</b>&nbsp;{{location}}</p>
</div>


However if I wish to implement
ng-repeat
in next paragraph it is working. But I want entire things to be in one line. Any suggestion, why it is not working and how should I put
ng-repeat
in above code.

**Edit: **I tried below code from one answer

<b ng-repeat="location in showData.City">Location: {{location}}</b>


However it is causing two problems

First


I expect result to be like Location: Banglore, India

while it is giving Location: Banglore, Location: India


Second I don't want my value to be in bold letters.

Answer
<div class="section">
    <p class="text-left">
        <strong>Designation:</strong>{{showData.Designation}}&nbsp;&nbsp;
        <strong>Company:</strong> &nbsp;{{showData.Company}}
        &nbsp;&nbsp;
        Location: <span ng-repeat="location in showData.City">{{location}}</span>
    </p>
</div>

If you need to show the cities, you can just join the entries in your controller and show them:

this.citiesJoined = showData.City.join(",");

HTML

Location: Location: {{citiesJoined}}
Comments