title: How to use forEach loop correctly in angular 2?
body: <p>I am new to Angular2 and here I am trying to loop through the array "mmEditorTypes" and checking the condition, if the condition is satisfied then I'll be executing the "open method".</p>
  
  <p>But whenever i execute the below code, I am getting this error :</p>
  
  <p>portalModeService: loading of portalMode threw exception: </p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'forEach' of undefined".</p>
  </blockquote>
  
  <p>Could someone let me know how to fix this error?</p>
  
  <p><strong>porta.service.ts :</strong></p>
  
  <pre><code>function isAppContained(viewState, appType){
        let angular:any;
        let isContained = false;
        angular.forEach(viewState.appViewStates, function (appViewState) {
          if (appViewState.signature.appType === appType) {
            isContained = true;
          }
        });
        return isContained;
      }
  </code></pre>