title: unable to change data of an array
body: <p>It's some javascript related issue (not angular but context is angular), trying to sort out for hours without any success.</p>
  
  <p>I'm trimming down the content to shorter paragraphs and assigning the subcontent back to the array's content property but it's still the larger contents that shows up.</p>
  
  <pre><code>controller: function($scope, $location) {
      this.$scope = $scope;
  
      this.$scope.folio = {
          "deleted"       : null,
          "free"          : null,
          "id"            : null,
          "lastModified"  : null,
          "productId"     : null,
          "publication"   : null,
  
          articles: []
      };
  },
  
  result: function(folio) {
      this.$scope.folio.articles.length = 0;
  
      this.$scope.folio.deleted = folio.deleted
      this.$scope.folio.free = folio.free
      this.$scope.folio.id = folio.id
      this.$scope.folio.lastModified = folio.lastModified
      this.$scope.folio.productId = folio.productId
      this.$scope.folio.publication = folio.publication
  
      for(var i=0; i&lt;folio.articles.length; i++) {
  
          for(var j=0; j&lt;folio.articles[i].pages.length; j++) {
              var content = folio.articles[i].pages[j].content
              var index = content.toLowerCase().indexOf("test".toLowerCase())
  
              if(index &gt; 150) { //if index is not within first 150 characters
                  content = content.substring(index - 25, index + 30)
              }
              //displays fine with the desired output
              console.log(content.replace(new RegExp("test", "gi"), "&lt;em&gt;" + "test" + "&lt;/em&gt;"))
  
              //assigning back to the array but for some reason it's not the trimmed output at the end
              folio.articles[i].pages[j].content = content.replace(new RegExp("test", "gi"), "&lt;em&gt;" + "test" + "&lt;/em&gt;")
          }
  
          //the article's pages are still full length
          this.$scope.folio.articles.push(folio.articles[i]); 
      }
  
      this.$scope.$apply();
  }
  </code></pre>