变量通过订阅获得值,但不显示前端
我正在将Ludessetting组件路由到功能映射组件。 当我导航到功能映射组件中时,我通过订阅该字典将词典存储在命名feature22中。当我在控制台中打印时,我可以看到在功能22中存储了DIC,但此值未反映在HTML前端侧
component.feature-mappent.ts file
import { Component, OnInit } from '@angular/core';
import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
import { AlldataService } from '../alldata.service';
import { HeadingService } from '../heading.service';
@Component({
selector: 'app-feature-mapping',
templateUrl: './feature-mapping.component.html',
styleUrls: ['./feature-mapping.component.css']
})
export class FeatureMappingComponent implements OnInit {
heading:string="Rule Setting"
features22:any={}
features33:any =[]
constructor(
private allDataService:AlldataService,
private headingService:HeadingService) {
}
ngOnInit(): void {
this.headingService.heading.emit(this.heading)
console.log()
this.allDataService.features22.subscribe(
(data:any)=>{
for(var key in data)
{
this.features33.push(key)
// this.features22[key] = data[key];
}
// this.features22.push(...data)
this.features22=data
console.log("this is in rule setting")
console.log(this.features22)
console.log(this.features33)
}
)
console.log(this.features22)
console.log(this.features33)
}
}
component.feature-mappent.html文件
<div class="row-custom">
<div class="section-heading1">Feature List</div>
<div class="container1-main">
<div> {{features33}}</div>
<div> {{heading}}</div>
<div class="container1" *ngFor="let feature of features22| keyvalue">
{{feature.key}}
<table class="table table-borderless">
<thead>
<tr>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody style="background-color: white;">
<tr>
<td scope="row" class="heading-tabledata">
<div class="para">{{feature.key}}</div>
</td>
<td class="drag-tabledata">
{{feature.value}}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
[console] [1] [1]:https://i.sstatic.net/odyd9.png
[在前端] [2] [2]:https://i.sstatic.net/mgbno.png
如何在HTML前端显示功能22?
I am routing from rulessetting component to feature-mapping component.
When I navigated into feature-mapping component, i am storing a dictionary in variable named feature22 by subscribing it. When i am print in console i can see that in feature22 a dic is stored but this value is not reflecting in html frontend side
component.feature-mapping.ts file
import { Component, OnInit } from '@angular/core';
import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
import { AlldataService } from '../alldata.service';
import { HeadingService } from '../heading.service';
@Component({
selector: 'app-feature-mapping',
templateUrl: './feature-mapping.component.html',
styleUrls: ['./feature-mapping.component.css']
})
export class FeatureMappingComponent implements OnInit {
heading:string="Rule Setting"
features22:any={}
features33:any =[]
constructor(
private allDataService:AlldataService,
private headingService:HeadingService) {
}
ngOnInit(): void {
this.headingService.heading.emit(this.heading)
console.log()
this.allDataService.features22.subscribe(
(data:any)=>{
for(var key in data)
{
this.features33.push(key)
// this.features22[key] = data[key];
}
// this.features22.push(...data)
this.features22=data
console.log("this is in rule setting")
console.log(this.features22)
console.log(this.features33)
}
)
console.log(this.features22)
console.log(this.features33)
}
}
component.feature-mapping.html file
<div class="row-custom">
<div class="section-heading1">Feature List</div>
<div class="container1-main">
<div> {{features33}}</div>
<div> {{heading}}</div>
<div class="container1" *ngFor="let feature of features22| keyvalue">
{{feature.key}}
<table class="table table-borderless">
<thead>
<tr>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody style="background-color: white;">
<tr>
<td scope="row" class="heading-tabledata">
<div class="para">{{feature.key}}</div>
</td>
<td class="drag-tabledata">
{{feature.value}}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
[In console ][1]
[1]: https://i.sstatic.net/OdYD9.png
[In front-end ][2]
[2]: https://i.sstatic.net/mgbNo.png
How I can display feature22 in html front-end ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论