AngularJS Arrays

0

Let’s look at an example of Angular JS expressions with arrays.

In this example, we are going to define an array which is going to hold the marks of a student in 4 subjects. In the view, we will display the value of these marks accordingly.

<!DOCTYPE html>
<html>
<head>
    <meta chrset="UTF 8">
    <title>Event Marksheet</title>
</head>
<body>

<script src="https://code.angularjs.org/1.6.9/angular-route.js"></script>
<script src="https://code.angularjs.org/1.6.9/angular.min.js"></script>

<h1> Script Guru Global Event</h1>

<div ng-app="" ng-init="marks=[21,25,19,22]">

    Student Marks<br>&nbsp;&nbsp;&nbsp;
    Subject1 : {{marks[0] }}<br>&nbsp;&nbsp;&nbsp;
    Subject2 : {{marks[1] }}<br>&nbsp;&nbsp;&nbsp;
    Subject3 : {{marks[2] }}<br>&nbsp;&nbsp;&nbsp;
    Subject4 : {{marks[3] }}<br>&nbsp;&nbsp;&nbsp;
</div>

</body>
</html>