title: Why do I get a message saying forEach is not a function?
body: <p>In typescript I defined:</p>
  
  <pre><code>class SubjectService implements ISubjectService {
  
      subject: any;
      subjectId: number = 0;
      subjects = {
          "1": { "id": 1, "name": "Java" },
          "100": { "id": 100, "name": "Test" }
      };
  
      static $inject = [
          "$http",
          "appConstant",
      ];
  
      constructor(
          public $http: ng.IHttpService,
          public ac: IAppConstant
          ) {
      }
  
  }
  </code></pre>
  
  <p>I then in my constructor have this code:</p>
  
  <pre><code>class SubjectController {
  
      static $inject = [
          "$scope",
          "subjectService"
      ];
  
      constructor(
          public $scope,
          public su: ISubjectService
          ) {
          $scope.su = su;
  
          $scope.rowClicked = (subject, $index) =&gt; {
              var self = this;
              if (subject.current &amp;&amp; subject.current == true) {
                  return;
              }
              su.subjects.forEach(function (subject) {
                  subject.current = false;
              });
              su.subject = subject;
              su.subject.current = true;
          }
  
      }
  
  }
  </code></pre>
  
  <p>But when this runs I am getting a message saying:</p>
  
  <p>TypeError: su.subjects.forEach is not a function
      at Scope.SubjectController.$scope.rowClicked (<a href="http://localhost:1810/app/controllers/SubjectController.js:12:25" rel="nofollow">http://localhost:1810/app/controllers/SubjectController.js:12:25</a>)</p>
  
  <p>Does anyone have any idea what might be wrong. I used similar code in other places but here it fails each time.</p>