AngularJS ng-repeat

DZ1EFM9PIK AngularJS allows me to loop through an array with the ng-repeat directive very easily.

(The ‘Resources’ tab will show you the JavaScript and css files I’ve included and the ‘Result’ tab will show you the output.)

Notice the ng-init initializes the array with a list of languages. ng-repeat="language in languages" will loop through the languages array assigning each element to the language variable. {{ language }} will output each of the languages in the array.

The example below uses an object and another loop to access the key/value pair instead of an array:

Disclosure: Some of the links on this site are “affiliate links.” This means if you click on the link and purchase the item, I will receive an affiliate commission.

Leave a Reply

Your email address will not be published. Required fields are marked *