Is there any String.startsWith(String) for angularJS

angularjs, javascript

Solution

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

Problem

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> ```

Original source