angular - 作为对象接收的角度数据
问题描述
我正在将数据从一个组件传递到另一个组件,但在接收端,我正在获取对象格式的数据,如图所示,我只需要这些数字作为输出 ,在此处输入图像描述
这是我写的代码
Component1.ts:-(这里我导航到component2):-
this.router.navigate(['/operation', { questions:JSON.stringify(this.que),
answers:JSON.stringify(this.answers), level:this.level, operation:this.operation } ]);
Component2.ts:-(该组件接收)
answer = [];
que = [];
level=1
operation=1
constructor(private route: ActivatedRoute) {
}
ngOnInit() {
this.route.paramMap.subscribe(params => {
this.que = JSON.parse(params.get("questions"))
this.answer = JSON.parse(params.get("answers"))
this.level = parseInt(params.get("level"))
this.operation = parseInt(params.get("operation"))
});
}
Component2.html:(这里我显示)
<div *ngIf="operation === 1">
<div class="app flex-row align-items-center">
<div class="container">
<div class="card-block">
<h4 class="card-title text-center">{{ i }}.) </h4>
<div *ngFor="let items of que| keyvalue">
<div *ngFor="let item of items| keyvalue">
{{ item.value | json }}
</div>
</div>
</div>
<h4 class="card-title text-center">
{{ answer }}
</h4>
</div>
我怎样才能获得仅数字的结果
解决方案
推荐阅读
- google-sheets - 如何使用 app google app 脚本显示其他表中的几个列以加入主表?
- python - 使用 python 访问 Wordpress 数据库
- php - 如何在 laravel 中的 DB::raw() 中添加 where
- c# - Xamarin 表单将数据传递到选项卡式页面
- android - 如何在 Android 中覆盖 UI 元素
- javascript - 似乎无法弄清楚如何正确删除子节点
- swift - 检测关于容器视图的 UIView 中心位置 - Swift - 以编程方式
- python - Keras 自定义损失函数 huber
- logging - 如何在生产日志中查看 SQL 参数值?
- azure-cosmosdb - 这是 Azure Cosmos DB 中的错误分区键方案吗?