Reputation: 372
I've tried to setup an angular2-seed project which works now but now I want to add PrimeNG to my environment but I got stuck with it.
off course my first step: was installing primeng and primeui
npm install primeng --save
npm install primeui --save
Then I added a mapping @ https://github.com/mgechev/angular2-seed/blob/master/tools/config/seed.config.ts#L129
My component looks like this:
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 file
<p-pieChart [value]="data" width="300" height="300"></p-pieChart>
This all wasn't enough: I think I still need to add the following css & js files but I don't know where!
<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>
and I'm not sure if the previous steps where correct as well. At the moment I got the error:
EXCEPTION: ReferenceError: Chart is not defined
Upvotes: 2
Views: 6573
Reputation: 417
This reply comes a bit late but anyway.
I got almost the same problems as you and after many hours of work i solved it for me. I`ve done all steps to get PrimeNg running like they told us on PrimeNG but my application was still not running.
I figured out that my problem was my System.JS
file.
This is my System.JS
and i got PrimeNG running with that.
And i placed my <script>
's like that:
<!-- CSS for PrimeUI -->
<link rel="stylesheet" type="text/css" href="node_modules/primeui/themes/bluesky/theme.css" />
<link rel="stylesheet" href="font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="node_modules/primeui/primeui-ng-all.min.css" />
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script>
<!-- JS for NG-Prime-->
<script src="node_modules/primeui/primeui-ng-all.min.js"></script>
<script>
System.config({
defaultJSExtensions: true,
packages: {
app: {
format: 'register'
}
},
map: {
'angular2': 'node_modules/angular2',
'primeng': 'node_modules/primeng'
}
});
System.import('app/boot').then(null, console.error.bind(console));
</script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
I'm not sure if that can help you but i hope so.
i can't help you with Chart.js because i never used it.
Upvotes: 0
Reputation: 372
Ah according to this page Chart.js should also be included as well!
Upvotes: 1