我正在使用 Visual Studio 2015 解决方案中的打字稿开发 Angular 2 应用程序。我已经阅读了 PrimeNG 网站中数据表的文档,但不明白为什么我实现的数据表没有显示。有人可以帮忙吗?
风险列表.component.ts
import { Component } from '@angular/core'
@Component({
selector: 'rm-risks',
templateUrl: 'app/risks/risk-list.component.html'
})
export class RiskListComponent {
pageTitle: string = 'Risk List';
risks: any[] = [
{
"riskId": 1,
"reference": "HISXX336",
"insuredName": "sdsdsdsdsd",
"inceptionDate": "March 19, 2016",
"riskType": "Test1",
"status": "Indication",
"grossPremium": "100",
"allocatedTo": "XYZ User",
"allocatedCompany": "XYZ"
},
{
"riskId": 2,
"reference": "HIXXXXX0",
"insuredName": "fgfgfgfgfg",
"inceptionDate": "April 25, 2016",
"riskType": "Test2",
"status": "Indication",
"grossPremium": "312.22",
"allocatedTo": "PQR User",
"allocatedCompany": "PQR"
}
];
风险列表.component.html
<h3 class="first">{{pageTitle}}</h3>
<p-dataTable [value]="risks" [rows]="10" [paginator]="true" [pageLinks]="3" [rowsPerPageOptions]="[5,10,20]">
<p-column field="reference" header="Reference"></p-column>
<p-column field="insuredName" header="Insured Name"></p-column>
<p-column field="inceptionDate" header="Inception Date"></p-column>
<p-column field="riskType" header="Risk Type"></p-column>
<p-column field="status" header="Status"></p-column>
<p-column field="grossPremium" header="Gross Premium"></p-column>
<p-column field="allocatedTo" header="Allocated To"></p-column>
<p-column field="allocatedCompany" header="Allocated Company"></p-column>
</p-dataTable>
app.component.ts
import { Component } from '@angular/core';
import { RiskListComponent } from './risks/risk-list.component';
import {DataTable} from 'primeng/primeng';
import {Column} from 'primeng/primeng';
@Component({
selector: 'my-app',
providers: [],
template: `
<div>
<h1>{{pageTitle}}</h1>
<rm-risks> </rm-risks>
</div>
`,
directives: [RiskListComponent]
})
export class AppComponent {
pageTitle: string = 'Test UK Trader';
}
索引.html
<!DOCTYPE html>
<html>
<head>
<title>Angular 2 Application</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="app/app.component.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="https://npmcdn.com/es6-shim@0.35.0/es6-shim.min.js"></script>
<script src="https://npmcdn.com/zone.js@0.6.12?main=browser"></script>
<script src="https://npmcdn.com/reflect-metadata@0.1.3"></script>
<script src="https://npmcdn.com/systemjs@0.19.27/dist/system.src.js"></script>
<!-- 2. Configure SystemJS -->
<script src="systemjs.config.js"></script>
<script>
System.import('app').catch(function(err){ console.error(err); });
</script>
</head>
<body>
<my-app>Loading..</my-app>
</body>
</html>