What does this construct look like in Typescript for Angular ?

0 votes

Asking about the angular.forEach() constructor used in my Angular 1 controllers. These are flagged as errors in TS and do not compile.

For example, I have one with a nested loop:

 _this.selectChildren = function (data, $event) {
  var parentChecked = data.checked;
  angular.forEach(_this.hierarchicalData, function (value, key) {
    angular.forEach(value.children, function (value, key) {
      value.checked = parentChecked;
    });
  });
};

What does this construct look like in Typescript for Angular 4?

Sep 8 in Angular by kartik
• 35,500 points
35 views

1 answer to this question.

0 votes

Hello @kartik,

try this.

 selectChildren(data, $event) {
      let parentChecked = data.checked;
       this.hierarchicalData.forEach(obj => {
          obj.forEach(childObj=> {
            value.checked = parentChecked;
         });
      });
    }

Hope it helps!!
Thank You!!

answered Sep 8 by Niroj
• 76,940 points

Related Questions In Angular

0 votes
1 answer

What is $watch() and it's use in AngularJS?

$watch() function is used to watch the ...READ MORE

answered Feb 3 in Angular by anonymous
• 76,940 points
193 views
0 votes
1 answer

What is the use of $eval in alert()?

Hey, kartik!! There is not much difference in ...READ MORE

answered Feb 4 in Angular by Niroj
• 76,940 points
150 views
0 votes
1 answer

What is $parse in Angularjs

Before we jump into the topic you ...READ MORE

answered Feb 4 in Angular by Niroj
• 76,940 points
519 views
0 votes
1 answer

What is so different about interpolate in AngularJS?

hii @kartik, In order to know about what ...READ MORE

answered Feb 4 in Angular by Niroj
• 76,940 points
289 views
0 votes
1 answer

What are the vulnerability related to PHP Form?

Hii, The $_SERVER["PHP_SELF"] variable can be used by ...READ MORE

answered Feb 13 in PHP by Niroj
• 76,940 points
201 views
+1 vote
1 answer

How can we send message multiple time to a specific person or group in whatsapp using loop?

Hii @kartik,  This is simple task to send single ...READ MORE

answered Feb 28 in Java-Script by Niroj
• 76,940 points
757 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27 in PHP by Niroj
• 76,940 points
176 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27 in PHP by Niroj
• 76,940 points
105 views
0 votes
1 answer

What is $routeParams used for in Angularjs?

Angularjs routeParams is a service that allows ...READ MORE

answered Feb 7 in Angular by Niroj
• 76,940 points
524 views