Skip to content

Commit faf668b

Browse files
committed
Document running apps with AoT and igniteui-angular2
1 parent 1a64a8f commit faf668b

File tree

1 file changed

+93
-8
lines changed

1 file changed

+93
-8
lines changed

README.md

Lines changed: 93 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,25 +259,110 @@ Component methods can be called by accessing the component from the view. For ex
259259
template: '<ig-grid #grid1
260260
[(options)]="gridOptions">
261261
<features>
262-
<paging [pageSize]="'2'"></paging>
263-
</features>
262+
<paging [pageSize]="'2'"></paging>
263+
</features>
264264
</ig-grid>',
265265
directives: [IgGridComponent]
266266
})
267-
export class AppComponent {
268-
private gridOptions: IgGrid;
269-
@ViewChild("grid1") myGrid: IgGridComponent;
267+
export class AppComponent {
268+
private gridOptions: IgGrid;
269+
@ViewChild("grid1") myGrid: IgGridComponent;
270270
private id: string;
271271
constructor() { ... }
272272
273-
ngAfterViewInit() {
274-
//call grid method
275-
var cell = this.myGrid.cellById(1, "Name");
273+
ngAfterViewInit() {
274+
//call grid method
275+
var cell = this.myGrid.cellById(1, "Name");
276276
//call grid paging method
277277
this.myGrid.featuresList.paging.pageIndex(2);
278278
}
279279
}
280280

281+
## Using Ignite UI Angular Components inside AOT app
282+
As a starting point, you can review the [Angular documentation on the subject](https://angular.io/docs/ts/latest/cookbook/aot-compiler.html), which provides a guide how to compile an app with AOT. Follow their instructions to AOT compile the quickstart app.
283+
284+
Once you have a running application compiled with AOT, the next step is to add the Ignite UI Components into this app. In this demo IgComboComponent is being added to the app, igCombo is an OSS widget and it is part of the ignite-ui npm package.
285+
First we need to install the required packages:
286+
- `npm install ignite-ui`
287+
- `npm install igniteui-angular2`
288+
- `npm install jquery-ui-bundle`
289+
290+
**Note**: You have to download the full Ignite UI product if you would like to use widgets which are not part of the OSS widgets. This is a [list](https://github.com/IgniteUI/ignite-ui#available-features-in-ignite-ui-open-source-version) of the controls available in the Open-source version
291+
292+
Then go to the app module and import the combo - `import 'ignite-ui/js/modules/infragistics.ui.combo.js';`. But before that add all the dependencies for it:
293+
294+
import 'jquery';
295+
import 'jquery-ui-bundle/jquery-ui.min.js';
296+
import 'ignite-ui/js/modules/infragistics.util.js';
297+
import 'ignite-ui/js/modules/infragistics.templating.js';
298+
import 'ignite-ui/js/modules/infragistics.datasource.js';
299+
import 'ignite-ui/js/modules/infragistics.ui.combo.js';
300+
301+
In addition, at the end import the IgniteUIModule:
302+
303+
import { IgniteUIModule } from 'igniteui-angular2';
304+
@NgModule({
305+
imports: [ BrowserModule, IgniteUIModule ],
306+
307+
})
308+
export class AppModule {}
309+
310+
In order to take advantage of the [Tree shaking](https://angular.io/docs/ts/latest/cookbook/aot-compiler.html#!#tree-shaking) the Rollup has to be set up.
311+
Open rollup-config.js, include igniteui-angular2 to `commonjs` plugin and add `namedExport` for jquery:
312+
313+
commonjs({
314+
include: ['node_modules/rxjs/**',
315+
'node_modules/igniteui-angular2/**',
316+
],
317+
namedExports: {
318+
'node_modules/jquery/dist/jquery.min.js': [ 'jquery' ]
319+
}
320+
}),
321+
322+
Additional plugin rollup-plugin-replace should be installed
323+
`npm install rollup-plugin-replace` in order to fix the offline compilation of Ignite UI util module.
324+
`this.Class` should be changed to `window.Class`, because the offline compilation is not having the same [context and this is changed to undefined](https://github.com/rollup/rollup/issues/942).
325+
326+
replace({
327+
// this is undefined for the specified context, so replace it with window to access Class
328+
include: 'node_modules/ignite-ui/js/modules/infragistics.util.js',
329+
values: { 'this.Class': 'window.Class' }
330+
}),
331+
332+
Now we are ready to use the IgComboComponent
333+
`<ig-combo [dataSource]="heroesCombo" [widgetId]="comboId" [textKey]="'name'" [valueKey]="'id'"></ig-combo>` in app.component.html
334+
And also define the used properties in AppComponent class:
335+
336+
export class AppComponent {
337+
comboId = 'combo1';
338+
showHeading = true;
339+
heroes = ['Magneta', 'Bombasto', 'Magma', 'Tornado'];
340+
heroesCombo = [{id: 0, name: 'Magneta'}, {id: 1, name:'Bombasto'}, {id: 2, name:'Magma'}, {id: 3, name:'Tornado'}];
341+
342+
toggleHeading() {
343+
this.showHeading = !this.showHeading;
344+
}
345+
}
346+
347+
At the end, apply Ignite UI styling. To achieve this, postcss plugin should be installed
348+
`npm install rollup-plugin-postcss`
349+
350+
Open rollup-config.js file and import postcss:
351+
352+
import postcss from 'rollup-plugin-postcss'
353+
354+
postcss({
355+
extensions: ['.css']
356+
}),
357+
358+
359+
[Download](https://github.com/IgniteUI/igniteui-angular2/files/975676/quickstart-igniteui-angular2-aot.zip) the modified app which uses the specified product. To run it with AOT:
360+
1. npm install
361+
2. npm run build:aot
362+
3. npm run serve
363+
364+
365+
281366
## Two-way Data Binding
282367
The following controls currently support two-way data binding:
283368

0 commit comments

Comments
 (0)