ng-init and ng-repeat Directive

ng-repeat Directive is used to repeat an HTML element for each item in the collection.
Below is a sample code for ng-repeat directive. I have used Visual Studio to write this code.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
    <title>ng-repeat Directive</title>
</head>
<body ng-app="">
    <div ng-init="contacts=[{name: 'William', phone:'9876543210'},{name:'John', phone:'7777666543'},{name:'Mike',phone:'7778456734'}]">
        <p>Below are the list of Contacts:</p>
        <ol>
            <li ng-repeat="contact in contacts">
                {{'Name: ' + contact.name + ', Phone: ' + contact.phone}}
            </li>
        </ol>
    </div>
</body>
</html>

Below is the output of the above code:

Power Platform Academy

Start or Upgrade your Career with Power Platform

Learn with Akanksha

Python | Azure | AI/ML | OpenAI | MLOps

Design a site like this with WordPress.com
Get started