Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
61
rated 0 times [  64] [ 3]  / answers: 1 / hits: 31498  / 11 Years ago, mon, january 13, 2014, 12:00:00

I have similar to following working code



<section class=row-fluid result ng-repeat=result in getResults()>
<p>{{result.name}}</p>
<p>{{result.link}}</p>
</section>


the result have another property called resultId
where result.resultId will return one of following source prefixes: One, Two,Three.



For example these are typical resultId: One3244243, One23036043, Two3890234, Three23114232



Whereas prefixes means:



One=Source ABC
Two=Source XYZ
Three=Source WXY


So, now I want to also display the sources of the each result based on result's id
prefixes:



<section class=row-fluid result ng-repeat=result in getResults()>
<p>{{result.name}}</p>
<p>{{result.link}}</p>
<p><!-- display 'Source ABC' if result.resultId starts with One --> </p>
<p><!-- display 'Source XYZ' if result.resultId starts with Two--> </p>
<p><!-- display 'Source WXY' if result.resultId starts with Three --> </p>

</section>

More From » angularjs

 Answers
11

Do ng-show=result.resultId.indexOf('One') == 0, etc.


[#73218] Saturday, January 11, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deannaalysonl

Total Points: 703
Total Questions: 101
Total Answers: 115

Location: Saint Helena
Member since Tue, Nov 3, 2020
4 Years ago
;