title: What is the best way to convert flat records into objects?
body: <p>I have a flashcard application in which I get a set of flashcard records from the server, then run through it in a ng-repeat loop. However, instead of looping through these flat records, I would like to loop through a collection of objects with methods that I can call, as I do in PHP.</p>
  
  <p>Is there an "AngularJS" way to do this, and if not, what is the best method to do this so that I can e.g. load a collection of flashcard objects with my records and then use this collection in multiple views with ng-repeat?</p>
  
  <p><strong>controller:</strong> </p>
  
  <pre><code>mainApp.controller('browseController', function ($scope, $http, $rootScope) {
      $http.get($rootScope.dataUrlPath, {
          params: {
              taskIdCode: 'getAllFlashcardsWithStacks'
          }
      }).success(function (data) {
          $scope.flashcards = data['flashcards'];
      });
  });
  </code></pre>
  
  <p><strong>view:</strong></p>
  
  <pre><code>&lt;div class="col-md-5"&gt;
      &lt;h1 class="pageTitle"&gt;Browse Flashcards&lt;/h1&gt;
      &lt;div ng-repeat="flashcard in flashcards"&gt;
          &lt;div&gt;{{flashcard.front}}&lt;/div&gt;
          &lt;div&gt;{{flashcard.back}}&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>What I would like to do is something like this:</p>
  
  <pre><code>&lt;div class="col-md-5"&gt;
      &lt;h1 class="pageTitle"&gt;Browse Flashcards&lt;/h1&gt;
      &lt;div ng-repeat="flashcard in flashcards"&gt;
          {{flashcard.displayAsRichInteractiveFlashcard()}}
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>But if possible, I would like to do it "the Angular way" and this seems to be getting away from how Angular works.</p>
  
  <p><strong>What is the best way to turn my records into a collection of rich objects so that I can access their rich methods from various views?</strong></p>