如何解决控制台上出现数字,字符串,布尔值的控制台错误找不到类型为“数字”的其他支持对象“ 100”
我已经实现了下面的代码,并在页面上正确显示了数据,但是我试图找出为什么它在控制台上显示错误,我尝试了多种方法来检查* ngIf =“(parameter.value |类型)==='数字'“ ,然后将每个参数都放在div中,但没有任何结果,我在控制台上遇到错误,无法找到解决方案来停止此错误。
我正在使用angular 10和“ primeng”:“ ^ 9.0.6”版本。
有人可以帮我吗?
谢谢。
在html文件中->
<p-accordion [multiple]="true">
<p-accordionTab [selected] ="true" *ngFor="let category of response.categories"
header="{{ category.name | translate}}">
<div class="panel-body request-details">
<div *ngFor="let parameter of category.parameters ">
<div >
<div class="col-md-12">
<div class="request-legend ng-binding col-md-3"
title="{{ parameter.name |translate}}">
{{ parameter.name|translate }}
</div>
<div class="col-md-9 param-value">
{{format( parameter.value) }}
</div>
</div>
</div>
<div *ngIf="isEmptyArray(parameter.value)" class="col-md-9 param-value">
Not defined</div>
<div *ngFor="let subparameter of parameter.value">
<div class="col-md-offset-3 col-md-9 param-value">
{{format(subparameter)}}
</div>
</div>
</div>
</div>
</p-accordionTab>
<!--</div>-->
</p-accordion>
在打字稿文件中->
this.service.getData().subscribe(
data => { this.response = data;
},error => {
});
在模型文件中->
export class Response {
name?: string;
categories?: Array<Object>;
}
在json文件中->
{
"name": "MSO","categories": [
{
"name": "MSO_01","parameters": [
{
"name": "MSO_001","value": "Mso 2"
},{
"name": "MSO_002","value": null
}
]
},{
"name": "MSO_0023","parameters": [
{
"name": "MSO_005","value": "MSO_90"
},{
"name": "MSO_090","value": 3
},{
"name": "MSO_089","value": null
},{
"name": "MSO_789",]
}
错误
core.js:4197 ERROR Error: Cannot find a differ supporting object 'mso' of type 'string'. NgFor only supports binding to Iterables such as Arrays.
at NgForOf.ngDoCheck (common.js:3191)
at callHook (core.js:3042)
at callHooks (core.js:3008)
at executeInitAndCheckHooks (core.js:2960)
at refreshView (core.js:7331)
at refreshEmbeddedViews (core.js:8408)
at refreshView (core.js:7340)
at refreshEmbeddedViews (core.js:8408)
at refreshView (core.js:7340)
at refreshComponent (core.js:8454)
defaultErrorLogger @ core.js:4197
core.js:4197 ERROR Error: Cannot find a differ supporting object '3' of type 'number'. NgFor only supports binding to Iterables such as Arrays.
at NgForOf.ngDoCheck (common.js:3191)
at callHook (core.js:3042)
at callHooks (core.js:3008)
at executeInitAndCheckHooks (core.js:2960)
at refreshView (core.js:7331)
at refreshEmbeddedViews (core.js:8408)
at refreshView (core.js:7340)
at refreshEmbeddedViews (core.js:8408)
at refreshView (core.js:7340)
at refreshComponent (core.js:8454)
defaultErrorLogger @ core.js:4197
3core.js:4197 ERROR Error: Cannot find a differ supporting object 'true' of type 'boolean'. NgFor only supports binding to Iterables such as Arrays.
at NgForOf.ngDoCheck (common.js:3191)
at callHook (core.js:3042)
at callHooks (core.js:3008)
at executeInitAndCheckHooks (core.js:2960)
at refreshView (core.js:7331)
at refreshEmbeddedViews (core.js:8408)
at refreshView (core.js:7340)
at refreshEmbeddedViews (core.js:8408)
at refreshView (core.js:7340)
at refreshComponent (core.js:8454)
defaultErrorLogger @ core.js:4197
core.js:4197 ERROR Error: Cannot find a differ supporting object '1' of type 'number'. NgFor only supports binding to Iterables such as Arrays.
at NgForOf.ngDoCheck (common.js:3191)
at callHook (core.js:3042)
at callHooks (core.js:3008)
at executeInitAndCheckHooks (core.js:2960)
at refreshView (core.js:7331)
at refreshEmbeddedViews (core.js:8408)
at refreshView (core.js:7340)
at refreshEmbeddedViews (core.js:8408)
at refreshView (core.js:7340)
at refreshComponent (core.js:8454)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。