error isERROR错误:尝试区分'[{“ opened”:“ 2”,“ closed”:“ 2”,“ assigned”:“ 2”,“ reopen”:“ 1时出错 }]'。仅允许数组和可迭代对象
1。我在console中获得数据,但是我没有在浏览器中对数据进行评估 2.我在这里使用* ngFor评估数据。
这是我的代码。
HTML
<div class="row">
<div class="container-fluid">
<div class="col-xl-2 col-lg-4 col-md-4 pl-2 pr-2 mb-2 text-left">
<button type="button" class="btn btn-primary pp mb-1" style="height:70px;width:190px" data-container="body" data-toggle="tooltip" data-placement="top" data-content="Captured higher Email pref optin of 60K than normal 35K, Store sales higher than normal, Myclient captured more product preferences of 30K than normal 20K">
<div class="col-md-2">
<span *ngFor="let post of results">{{post.opened}}</span><br>
<i class="fa fa-user mr-2"></i>Opened
</div>
</button>
</div>
这是我的组件。
import { Component, ViewEncapsulation } from '@angular/core';
import { AppSettings } from '../../../app.settings';
import { Settings } from '../../../app.settings.model';
import { BatchService } from '../../config/batchnew/batch.service';
import { Router } from '@angular/router';
@Component({
selector: 'app-info-panels',
templateUrl: './info-panels.component.html',
encapsulation: ViewEncapsulation.None
})
export class InfoPanelsComponent {
results:any = [];
constructor (public appSettings:AppSettings,private router: Router,private dataservice:BatchService)
{
this.settings = this.appSettings.settings;
}
ngOnInit() {
this.dataservice.getData().subscribe((readdata)=>{this.results=readdata,console.log(this.results)})
jQuery('.tt').tooltip();
jQuery('.pp').popover();
}
public previousShowMenuOption:boolean;
public previousMenuOption:string;
public previousMenuTypeOption:string;
public settings: Settings;
public checkAppSettingsChanges(){
if(this.previousShowMenuOption != this.settings.theme.showMenu ||
this.previousMenuOption != this.settings.theme.menu ||
this.previousMenuTypeOption != this.settings.theme.menuType){
return true;
}
return false;
}
public initPreviousSettings(){
this.previousShowMenuOption = this.settings.theme.showMenu;
this.previousMenuOption = this.settings.theme.menu;
this.previousMenuTypeOption = this.settings.theme.menuType;
}
}
这是我的服务代码。
import {Injectable} from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Batch } from './batch.model';
import { Observable } from 'rxjs/observable';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};
@Injectable()
export class BatchService {
constructor(private http:HttpClient) {}
private Dashbord=' https://je2ngjw0w0.execute-api.us-east-1.amazonaws.com/dev/dashboard';
public getData():Observable<any[]>
{
return this.http.get<any[]>(this.Dashbord);
}