Hướng dẫn display array in html angular - mảng hiển thị trong góc html

Tôi nhận được tất cả dữ liệu JSON từ WS như thế này:

{
  "StatusCode":0,
  "StatusMessage":"OK",
  "StatusDescription":   
   [
      {"homeboxpackage_id":"1",
        "active":0,
        "homebox_id":"11",
        "serial_number":"serialn1",
        "user_id":"31", 
        "sensors": { 
              "0":{
                    "sensor_serial":"sensorserial1",
                    "sensors_id":"11E805BA6732C3DB"
              }, 
              "1":{
                    "sensor_serial":"sensorserial2", 
                    "sensors_id":"11E805BA6F1E6CE9"
              }, 
              "2":{
                    "sensor_serial":"sensorserial3", 
                    "sensors_id":"11E805BA7716C775"
              }
        }
    }
  ]

Trong mã HTML, tôi muốn hiển thị các cảm biến dữ liệu trong danh sách, nhưng DOS không hiển thị. Mã HTML của tôi:

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}

Homeboxsp nằm trong thành phần.ts

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );

hình ảnh

[1]: https://i.stack.imgur.com/qxrtr.png

Cảm ơn bạn

Cho một mảng & nhiệm vụ là in mảng đã cho ở định dạng bảng bằng cách sử dụng angularjs.

Trong JavaScript, dữ liệu có thể được lưu trữ dưới dạng mảng. Mỗi mục mảng có lập chỉ mục duy nhất, bắt đầu từ 0. Nhưng điều gì sẽ xảy ra nếu nhà phát triển muốn hiển thị tất cả các mục trong mảng, trên trang web. Một cách có thể là chạy một vòng lặp, bắt đầu từ 0 đến giá trị của (mảng.length () - 1). Tuy nhiên, điều này là không khả thi trong khi xử lý dữ liệu JSON, trong đó có thể tồn tại một mảng khác bên trong một mảng đã tồn tại. & NBSP;

Giải pháp tốt nhất có thể cho việc này đã được cung cấp bởi angularjs.an mảng có thể được in ở định dạng bảng bằng cách sử dụng chỉ thị ’ng-lặp lại của angularjs. Ng-lặp lại giúp lặp lại các mục trong phần tử thu thập. Chỉ thị này rất hữu ích trong khi xử lý một bộ sưu tập các đối tượng. & NBSP;An array can be printed in tabular format using the ‘ng-repeat’ directive of AngularJS. ‘ng-repeat’ helps in looping through the items in the collection element. This directive is very helpful while dealing with a collection of objects. 

Ví dụ 1: Ví dụ này minh họa việc kết xuất mảng ở dạng bảng bằng cách sử dụng Chỉ thị lặp lại trong AngularJS. This example illustrates the rendering of the array in the tabular form using the ng-repeat directive in AngularJS.

HTML

<html>

<head>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1<
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
3
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
4
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
5

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
3>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1<
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
2>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
5

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
7

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
9

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
{{x}}
1

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
{{x}}
3

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
{{x}}
5

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
{{x}}
7

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
{{x}}
1

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
2>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7head>

<8 9

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
5<1 <2
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
5<4>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1<<8 h

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1<html7html8html7>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1<>3>4>3>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1<>9 <0
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
5<22

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4<<6>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6<head0>

head2<head4head5head4>

head2<head4

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
01head4>

head2<head4

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
07head4>

head2<head4

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
13head4>

head2<head4

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
19head4>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7head0>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7<6>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4<head0
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
33
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
5
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
35>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6<
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
40
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6<
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
46
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6<
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
52
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6<
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
58
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6<
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
64
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7head0>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7>9>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
78>

<

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
3>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
82

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
84

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
86

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
88

head2

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
90

head2

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
92

head2

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
94

head2

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
96

head2

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
98

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
00

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
02

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
04

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
06

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
08

head2

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
98

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
00

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
14

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
16

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
18

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
20

head2

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
98

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
00

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
26

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
28

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
30

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
32

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
34

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
00

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
38

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
40

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
42

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
44

head2

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
34

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
{{x}}
1

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
50

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
52

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
3>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7html>

Giải thích: ‘ng-app‘ và bộ điều khiển ‘ng‘ của ứng dụng này đã được đặt tên tương ứng ‘myApp, và‘ listControll. Trong, một mảng có tên ‘itemDetails đã được tạo và lưu trữ trong biến phạm vi. Mảng chứa một danh sách các người chiến thắng top 5 Grand Slam trong quần vợt nam. & NBSP; The ng-app and the ng-controller of this application have been named ‘myApp’, and ‘ListController’ respectively. In the

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6<head0>

head2<head4

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
01head4>

head2<head4

{{x}}
56head4>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7head0>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7<6>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4<head0
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
33
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
5
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
35>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6<
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
46
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39>

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
6<
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39
{{x}}
83
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
39__

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7head0>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7>9>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
78>

<

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
3>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
82

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
103

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
88

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
607

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
609

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
00

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
613

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
615

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
00

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
619

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
609

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
00

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
625

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
615

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
00

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
631

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
615

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
{{x}}
1

 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
4
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
50

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
1
 this.ws.homeboxPGetAll().subscribe(
      homeboxsp => {
        this.homeboxsp = homeboxsp; // in console display all my array in array
           }
    );
52

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7
  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
3>

  
  • {{item.sensors}}
Serial Number Sensor Serial
{{item.serial_number}} {{item.active}}
7html>

Giải thích: Ví dụ này rất giống với ví dụ trước. Trong trường hợp này, chúng tôi đã tạo một mảng và đặt tên nó là ‘itemDetails. Chúng tôi sẽ lưu trữ mảng này trong đối tượng phạm vi. Dịch vụ ‘ng-repeat, sẽ lặp lại thông qua mảng, nhận một mục tại một thời điểm từ mảng và sau đó hiển thị nó trên trang web ở định dạng bảng. This example is very much similar to the previous example. In this case, we created an array and named it ‘itemsDetails’. We will store this array in the scope object. The ‘ng-repeat’ service will iterate through the array, get one item at a time from the array, and then display it on the webpage in the tabular format.

Output:  

Hướng dẫn display array in html angular - mảng hiển thị trong góc html


Làm thế nào để in mảng trong html Angular?

Một mảng có thể được in ở định dạng bảng bằng cách sử dụng chỉ thị 'ng-repeat' của angularjs.'NG-Repeat' giúp lặp qua các mục trong phần tử thu thập.Chỉ thị này rất hữu ích trong khi xử lý một bộ sưu tập các đối tượng.using the 'ng-repeat' directive of AngularJS. 'ng-repeat' helps in looping through the items in the collection element. This directive is very helpful while dealing with a collection of objects.

Làm thế nào để bạn hiển thị dữ liệu trong một mảng trong HTML?

foreach (phần tử => {document.getEuityById ('result'). InsideHtml += `$ {Element}`; // ở đây kết quả là id của div có trong DOM});};Mã này đưa ra giả định rằng div mà chúng tôi muốn hiển thị các phần tử của mảng có ID 'kết quả'. getElementById('result'). innerHTML += `
${element}

`; // here result is the id of the div present in the DOM }); };
This code makes the assumption that the div in which we want to display the elements of array has an id 'result'.