【发布时间】:2020-10-24 23:49:18
【问题描述】:
我已经按照我的要求实施了 PrimeNG 的组织结构图。我来自 TreeNode 类型数组的数据在 UI 中正确呈现,但设计不是。
以下是我的代码:
app.module.ts
import {OrganizationChartModule} from 'primeng/organizationchart';
imports: [ OrganizationChartModule ]
thankyou.component.ts
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { ApplicationService } from '../service-application/application.service';
import {TreeNode} from 'primeng/api';
@Component({
selector: 'app-thankyou',
templateUrl: './thankyou.component.html',
styleUrls: ['./thankyou.component.css'],
encapsulation: ViewEncapsulation.None
})
export class ThankyouComponent implements OnInit {
totObtainedMarks: number = 0;
totTotalMarks: number = 0;
marks: TreeNode[];
constructor(public appService: ApplicationService) {}
ngOnInit() {
let result = [];
for(let i of this.appService.result) {
let mark: any;
this.totObtainedMarks += i.obtainedMarks;
this.totTotalMarks += i.totalMarks;
mark = {
label: i.questionCategory + ': ' + i.obtainedMarks.toString() + '/' + this.totTotalMarks.toString()
};
result.push(mark);
}
this.marks = [{
label: 'Total: ' + this.totObtainedMarks.toString() + '/' + this.totTotalMarks.toString(),
children: result
}];
}
}
thankyou.component.html
<p-organizationChart [value]="marks"></p-organizationChart>
我按照官方文档进行了创建,但仍然无法理解问题所在。 请帮帮我。
【问题讨论】:
-
确保
ThankyouComponent在 app.module 中声明,而不是在其他模块中,您是否看到任何控制台错误? -
没有控制台错误并且组件被声明,“也不是其他模块”是什么意思?
-
我的意思是“而不是任何其他模块”对不起也是一个错误,只要在 app.moduel 中声明了“ThankYouComponent”,它看起来对我来说很好。
-
是的,这就是我感到困惑的原因。只有样式没有呈现:(
-
@Avishek 您是否为任何 PrimeNG 组件添加了所需的 CSS 引用?
标签: angular user-interface frontend primeng angular9