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, 2020 in Angular by kartik
• 37,520 points
731 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!!

To know more about Angular, It's recommended to join Angular Training today.

answered Sep 8, 2020 by Niroj
• 82,840 points

Related Questions In Angular

0 votes
1 answer

What is single-page application in angular?

In Angular, a single-page application is a ...READ MORE

answered Feb 19, 2024 in Angular by Digna
450 views
0 votes
0 answers

How to change the value of an Observable in TypeScript Angular?

How to change the value of an ...READ MORE

Nov 26, 2024 in Angular by Nidhi
• 5,060 points
71 views
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, 2020 in Angular by anonymous
• 82,840 points
2,565 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, 2020 in Angular by Niroj
• 82,840 points
1,390 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, 2020 in PHP by Niroj
• 82,840 points
3,266 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, 2020 in Java-Script by Niroj
• 82,840 points
18,923 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, 2020 in PHP by Niroj
• 82,840 points
3,310 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, 2020 in PHP by Niroj
• 82,840 points
1,376 views
0 votes
1 answer

What is $routeParams used for in Angularjs?

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

answered Feb 7, 2020 in Angular by Niroj
• 82,840 points
2,959 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP