Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any String.startsWith(String) for angularJS

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>
like image 743
Watt Avatar asked Jan 13 '14 05:01

Watt


1 Answers

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

like image 77
probablyup Avatar answered Oct 19 '22 18:10

probablyup