how to show a particular alphabet item of array in ng-repeat?

Viewed 1360

i have two arrays one for alphabets and second for tags.. So i want to show only same alphabets items in that particular alphabet category example -- apple has to come in A category and zoo has to come in Z category...

fiddle link http://jsfiddle.net/4dGxn/149/

html

<div class="form-group" ng-controller="mainCtrl">
  <div ng-repeat="alp in alpha">
  <h2>{{alp}}</h2>
    <ul>
      <li ng-repeat="tag in tags">{{tag}}</li>
    </ul>
  </div>
</div>

angular

var app = angular.module("app", []);

app.controller("mainCtrl", ['$scope', function($scope){

  $scope.alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p","q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];

  $scope.tags = ["apple", "dog", "cat", "dad", "baby", "zoo", "love", "hate", "rat", "room", "home", "age", "bad"];

}]);
3 Answers
Related