Angular. foreach method User Guide _ AngularJS-js tutorial

Source: Internet
Author: User
This article mainly introduces the format and parameters used by angular. foreach loop method. It is a very basic article and has its own lifecycle with reference to angular. Loop to the variable reset value of an angular listener. It is better to use the loop method that comes with angular. . "Angular. foreach"

Format:

The Code is as follows:


Var objs = [{a: 1}, {a: 2}];
Angular. forEach (objs, function (data, index, array ){
// Data is equivalent to array [index]
Console. log (data. a + '=' + array [index]. );
});

The parameters are as follows:

Objs: set to be traversed

Data: Repeat the current data

Index: The current index

Array: the set to be traversed. The objs is transmitted once every time it passes through.

You do not need to write the following two parameters:

The Code is as follows:


Var objs = [{a: 1}, {a: 2}];
Angular. forEach (objs, function (data ){
Console. log (data. );
});

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.