Home  >  Article  >  Web Front-end  >  Detailed example of AngularJS traversal to obtain array elements

Detailed example of AngularJS traversal to obtain array elements

小云云
小云云Original
2018-05-19 16:57:393330browse

This article mainly introduces the method of AngularJS traversal to obtain array elements, involving AngularJS simple array traversal and element acquisition related operation skills. Friends in need can refer to it, I hope it can help everyone.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>获取数组的元素例子</title>
  <script src="angular.min.js"></script>
  <script>
    var app=angular.module("lesson",[]);
    app.controller("oneCtrl",function($scope){
    });
  </script>
</head>
<body ng-app="lesson" ng-controller="oneCtrl" ng-init="Week=[&#39;Mon&#39;,&#39;Tue&#39;,&#39;Wen&#39;,&#39;Thu&#39;,&#39;Fri&#39;,&#39;Sat&#39;,&#39;Sun&#39;]">
    <!--循环获取数组里的元素start-->
    获取数组所有元素:
    <ul ng-repeat="a in Week">
      <li>
        <b style="color: green">{{a}}</b>
      </li>
    </ul>
    <!--获取数组单个元素-->
    获取数组单个元素:{{Week[0]}}
    <!--end-->
</body>
</html>

Run results:

Related recommendations:

Analysis of the path method of converting php array to string to obtain array representation

Detailed explanation of AngularJS using ng-repeat to traverse two-dimensional array elements

Several methods of php traversing two-dimensional arrays

The above is the detailed content of Detailed example of AngularJS traversal to obtain array elements. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn