I have this situation where I want to call a function to display the correct html mark up. Here is my current code:
<li ng-repeat="data in myBlock.myData">
<div ng-if="data.type=='Jonh'">
<div class='row'>
<div class='col'>
this is text for Jonh
</div>
</div>
</div>
<div ng-if="data.type=='Roy'">
<div class='row'>
<div class='col'>
Roy will have a different text
</div>
</div>
</div>
<div ng-if="data.type=='Kevin'" >
<div class='row'>
<div class='col'>
Kevin text is also different
</div>
</div>
</div>
</li>
I would like to combine all the ngif into a function called "showField(name)" that will check and return the right html mark up. How could that be done? My final html mark up should look something like this:
<li ng-repeat="data in myBlock.myData">
<div *ngIf="showField(data.type)">
//Not sure how to implement this part
</div>
</li>