Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  5] [ 2]  / answers: 1 / hits: 39443  / 6 Years ago, tue, january 23, 2018, 12:00:00

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.



But whenever i execute the below code, I am getting this error :



portalModeService: loading of portalMode threw exception:




TypeError: Cannot read property 'forEach' of undefined.




Could someone let me know how to fix this error?



porta.service.ts :



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;
}

More From » angular

 Answers
8

You cannot use angular.forEach with angular , its with angularjs.



use



for (let appViewState of viewState.appViewStates) {
if (appViewState.signature.appType === appType) {
isContained = true;
}
}

[#55395] Thursday, January 18, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
latrelllloydb

Total Points: 449
Total Questions: 92
Total Answers: 100

Location: French Polynesia
Member since Tue, Jul 7, 2020
4 Years ago
;