AngularJS Arrays


AngularJS Arrays : AngularJS arrays are same as the javaScript arrays. You can perform operation same as the javaScript arrays.


AngularJS Arrays simple Example using Expressions

You can access array elements same as javaScript.

<div ng-app="" ng-init="myArr=['First Item','Second Item']"  >

    <p> {{myArr[0] + " , " +myArr[1]}}</p>

</div>

Example 1

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
</head>

<body>
<div ng-app="" ng-init="myArr=['First Item','Second Item']"  >

    <p>Hi {{myArr[0] + " , " +myArr[1]}}</p>

</div>

</body>
</html>

Try it »

Example of AngularJS Arrays with ng-bind

Example 2

<!DOCTYPE html>
<html lang="en">
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
</head>
<body>
<div ng-app="" ng-init="myArr=['First Item','Second Item']" >
    <p><span ng-bind ="myArr.str1 + ',' + myArr.str2"></span></p>
</div>
</body>
</html>

Try it »


User Ans/Comments

📖 Read More


Advertisements