Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 我需要以角度显示python数组_Django_Python 3.x_Angular - Fatal编程技术网

Django 我需要以角度显示python数组

Django 我需要以角度显示python数组,django,python-3.x,angular,Django,Python 3.x,Angular,这是数组 [ { "TO":"test@gmail.com", "FROM":"nathanoluwaseyi@gmail.com", "SUBJECT":"subject 1", "NAME":"Oluwaseyi Oluwapelumi", "MESSAGE-DATE":[ [ "Hey eniayomi heeyyy", "2019-12-03 20:49:0

这是数组

[
   {
      "TO":"test@gmail.com",
      "FROM":"nathanoluwaseyi@gmail.com",
      "SUBJECT":"subject 1",
      "NAME":"Oluwaseyi Oluwapelumi",
      "MESSAGE-DATE":[
         [
            "Hey eniayomi heeyyy",
            "2019-12-03 20:49:07"
         ]
      ]
   },
   {
      "TO":"test@gmail.com",
      "FROM":"pelz@gmail.com",
      "SUBJECT":"Thanks for contacting R",
      "NAME":"",
      "MESSAGE-DATE":[
         [
            "Thanks for contacting me! Once i check my email, i shall definitely get back.",
            "2019-08-18 19:48:10"
         ],
         [
            "will check it.",
            "2019-08-18 19:48:10"
         ]
      ]
   }
]

我需要它显示在有角度的前端

这是mail.component.html文件

<div class="card-body p-0">
                      <div class="float-left" style="width: 330px; height: 430px; border-right: 1px solid #dad9d9; overflow-x: hidden; overflow-y: auto;">
                          <div class="p-2 profile-card" style="width: 315px; height: 100px; border-bottom: 1px solid #dad9d9;" *ngFor="let mail of dataservice.data; let i = index;" (click)="viewMail(mail.MESSAGE_DATE,mail.FROM,mail.NAME,mail.DATE,i)" [ngClass]="{'highlight': selectedIndex === i}">
                              <div class="row">
                                  <div class="col-md-3 pt-2">
                                      <div class="rounded-circle shadow" style="background-image: url('images/avt.jpg'); background-repeat: round; height: 70px; width: 70px;">
                                          <div style="height: 20px; width: 20px; border: 3px solid white;" class="rounded-circle bg-success"></div>
                                      </div>
                                  </div>
                                  <div class="col-md-7 p-0 pl-3 pt-4" style="line-height: 12px;">
                                      <p style="font-size:18px;"><b>{{mail.FROM}}</b></p>
                                      <p style="font-size:13px;">{{mail.NAME }}.</p>
                                  </div>
                                  <div class="col-md-2 p-0 pt-3" style="line-height:11px;">
                                      <p class="text-secondary" style="font-size:12px;">20m <i class="fa fa-star fa-md" aria-hidden="true"></i></p>
                                  </div>
                              </div>
                          </div>
这是mail.component.ts文件

  viewMail(mail, mailer, mailee, user_date, _index: number) {
    this.router.navigate(['mail/'+ mailer])
    console.log(mail)
    console.log(mailer)
    console.log(user_date)
    this.message = ''
    sessionStorage.setItem('mailer', mailer)
    sessionStorage.setItem('mailee', mailee);
    sessionStorage.setItem('user_date', user_date)
    console.log(sessionStorage.getItem('mailer'))
    this.user_message = mail;
    this.mailee = mailee;
    this.user_date = user_date;
    this.selectedIndex = _index;
  }

我做错了什么事。我唯一要展示的是mail.FROM和mail.SUBJECT。我知道这是因为台面部分的阵列。我不知道该怎么办

在Data.service.ts中

在mail.component.ts中

public data: Array<any> = []; 
    constructor(public dataSrv: DataService <-- this is the class name of the data service you created; import it)




 ngOnInit(){
         this.dataSrv.mail_det().subscribe(result =>{
        console.log(result); <-- your api response; 
this.data = result;
}, error => {console.log(error);
});
            }
在mail.component.html中

<div class="card-body p-0">
                      <div class="float-left" style="width: 330px; height: 430px; border-right: 1px solid #dad9d9; overflow-x: hidden; overflow-y: auto;">
                          <div class="p-2 profile-card" style="width: 315px; height: 100px; border-bottom: 1px solid #dad9d9;" *ngFor="let mail of data; let i = index;" (click)="viewMail(mail.MESSAGE_DATE,mail.FROM,mail.NAME,mail.DATE,i)" [ngClass]="{'highlight': selectedIndex === i}">
                              <div class="row">
                                  <div class="col-md-3 pt-2">
                                      <div class="rounded-circle shadow" style="background-image: url('images/avt.jpg'); background-repeat: round; height: 70px; width: 70px;">
                                          <div style="height: 20px; width: 20px; border: 3px solid white;" class="rounded-circle bg-success"></div>
                                      </div>
                                  </div>
                                  <div class="col-md-7 p-0 pl-3 pt-4" style="line-height: 12px;">
                                      <p style="font-size:18px;"><b>{{mail.FROM}}</b></p>
                                      <p style="font-size:13px;">{{mail.NAME }}.</p>
                                  </div>
                                  <div class="col-md-2 p-0 pt-3" style="line-height:11px;">
                                      <p class="text-secondary" style="font-size:12px;">20m <i class="fa fa-star fa-md" aria-hidden="true"></i></p>
                                  </div>
                              </div>
                          </div>

MESSAGE\u DATE来自数组,我这样命名问题是如何选择mail.MESSAGE\u DATE的值?您只对mail.component.ts文件进行了更改,对吗?我不明白您的意思did@EniayomiOluwaseyi对你有用吗?我更改了data service mail_det函数,在mail.component.ts中调用了data service mail_det函数,并在html中更改了这一行
public data: Array<any> = []; 
    constructor(public dataSrv: DataService <-- this is the class name of the data service you created; import it)




 ngOnInit(){
         this.dataSrv.mail_det().subscribe(result =>{
        console.log(result); <-- your api response; 
this.data = result;
}, error => {console.log(error);
});
            }
<div class="card-body p-0">
                      <div class="float-left" style="width: 330px; height: 430px; border-right: 1px solid #dad9d9; overflow-x: hidden; overflow-y: auto;">
                          <div class="p-2 profile-card" style="width: 315px; height: 100px; border-bottom: 1px solid #dad9d9;" *ngFor="let mail of data; let i = index;" (click)="viewMail(mail.MESSAGE_DATE,mail.FROM,mail.NAME,mail.DATE,i)" [ngClass]="{'highlight': selectedIndex === i}">
                              <div class="row">
                                  <div class="col-md-3 pt-2">
                                      <div class="rounded-circle shadow" style="background-image: url('images/avt.jpg'); background-repeat: round; height: 70px; width: 70px;">
                                          <div style="height: 20px; width: 20px; border: 3px solid white;" class="rounded-circle bg-success"></div>
                                      </div>
                                  </div>
                                  <div class="col-md-7 p-0 pl-3 pt-4" style="line-height: 12px;">
                                      <p style="font-size:18px;"><b>{{mail.FROM}}</b></p>
                                      <p style="font-size:13px;">{{mail.NAME }}.</p>
                                  </div>
                                  <div class="col-md-2 p-0 pt-3" style="line-height:11px;">
                                      <p class="text-secondary" style="font-size:12px;">20m <i class="fa fa-star fa-md" aria-hidden="true"></i></p>
                                  </div>
                              </div>
                          </div>