【发布时间】:2016-07-14 12:02:41
【问题描述】:
我尝试设置一个 angular2-seed 项目,该项目现在可以运行,但现在我想将 PrimeNG 添加到我的环境中,但我被它卡住了。
当然我的第一步是安装primeng和primeui
npm install primeng --save
npm install primeui --save
然后我添加了一个映射@https://github.com/mgechev/angular2-seed/blob/master/tools/config/seed.config.ts#L129
我的组件如下所示:
import {Component} from 'angular2/core';
import {CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/common';
import {PieChart} from 'primeng/primeng';
@Component({
selector: 'sd-stats',
moduleId: module.id,
templateUrl: './stats.component.html',
styleUrls: ['./stats.component.css'],
directives: [FORM_DIRECTIVES, CORE_DIRECTIVES, PieChart]
})
export class StatsComponent {
data: any[];
constructor() {
this.data = [{
value: 300,
color: '#F7464A',
highlight: '#FF5A5E',
label: 'Red'
},
{
value: 50,
color: '#46BFBD',
highlight: '#5AD3D1',
label: 'Green'
},
{
value: 100,
color: '#FDB45C',
highlight: '#FFC870',
label: 'Yellow'
}];
}
}
html文件
<p-pieChart [value]="data" width="300" height="300"></p-pieChart>
这还不够: 我想我仍然需要添加以下css和js文件但我不知道在哪里!
<link rel="stylesheet" type="text/css" href="node_modules/primeui/themes/delta/theme.css" />
<link rel="stylesheet" type="text/css" href="node_modules/primeui/primeui-ng-all.css" />
<script src="node_modules/primeui/primeui-ng-all.js"></script>
我不确定前面的步骤是否也正确。目前我得到了错误:
例外:ReferenceError:图表未定义
【问题讨论】: