Skip to content

Commit e9363ca

Browse files
authored
Merge pull request #154 from dkamburov/master
Add AoT support
2 parents 9f6af30 + 1e1ea59 commit e9363ca

18 files changed

+5324
-287
lines changed

README.md

Lines changed: 101 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
#Ignite UI components for Angular 2
1+
# Ignite UI components for Angular
22

33
[![NPM version](https://img.shields.io/npm/v/igniteui-angular2.svg?style=flat)](https://www.npmjs.com/package/igniteui-angular2)
44
[![Build Status](https://travis-ci.org/IgniteUI/igniteui-angular2.svg?branch=master)](https://travis-ci.org/IgniteUI/igniteui-angular2)
55
[![Coverage Status](https://coveralls.io/repos/github/IgniteUI/igniteui-angular2/badge.svg?branch=master)](https://coveralls.io/github/IgniteUI/igniteui-angular2?branch=master)
66

7-
Use the components found in `src\igniteui.angular2.ts` to use [Ignite UI](http://igniteui.com) controls in [Angular 2](https://angular.io/) applications. [Work with the running samples here](http://igniteui.github.io/igniteui-angular2).
7+
Use the components found in `src\igniteui.angular2.ts` to use [Ignite UI](http://igniteui.com) controls in [Angular](https://angular.io/) applications. [Work with the running samples here](http://igniteui.github.io/igniteui-angular2).
88

9-
#Requirements
9+
# Requirements
1010

1111
- [jQuery](http://www.jquery.com) v1.9.1 and later
1212
- [jQuery UI](http://www.jqueryui.com) v1.9.0 and later
13-
- [AngularJS 2](https://angular.io/) v2.0 beta and later
13+
- [Angular](https://angular.io/) v2.0 beta and later
1414
- [Ignite UI](http://www.igniteui.com) 15.2 and later
1515

16-
#Running the samples
16+
# Running the samples
1717
To run the samples, you need [Node.js](http://nodejs.org/) installed on your machine.
1818
Afterwards, from your terminal run the following commands:
1919

@@ -22,10 +22,10 @@ Afterwards, from your terminal run the following commands:
2222
3. `npm install`
2323
4. `npm start`
2424

25-
#Getting Started
25+
# Getting Started
2626

2727
## Initializing controls
28-
In an Angular 2 application, Ignite UI controls support markup initialization which is done by using custom tags.
28+
In an Angular application, Ignite UI controls support markup initialization which is done by using custom tags.
2929

3030
### Custom tags
3131
Each control implements a custom tag component where the tag name is formed by splitting each capital letter in the control name with the `-` symbol.
@@ -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

@@ -303,7 +388,7 @@ Since we need the code coverage of the `igniteui.angular2.js` file itself, we us
303388

304389
---------------------------------------
305390

306-
##What is Ignite UI?
391+
## What is Ignite UI?
307392
[![Ignite UI Logo](http://infragistics-blogs.github.io/github-assets/logos/igniteui.png)](http://www.igniteui.com)
308393

309394
[Ignite UI](http://igniteui.com/) is an advanced HTML5+ toolset that helps you create stunning, modern Web apps. Building on jQuery and jQuery UI, it primarily consists of feature rich, high-performing UI controls/widgets such as all kinds of charts, data visualization maps, (hierarchical, editable) data grids, pivot grids, enhanced editors (combo box, masked editors, HTML editor, date picker, to name a few), flexible data source connectors, and a whole lot more. Too many to list here - check out [the site](http://igniteui.com/) for more info and to [download](https://igniteui.com/download) a trial.

dist/npm/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "igniteui-angular2",
33
"version": "1.0.9",
4-
"description" : "A packaged version of Ignite UI components for Angular2",
4+
"description" : "A packaged version of Ignite UI components for Angular",
55
"license": "MIT",
66
"typings": "igniteui.angular2.d.ts",
77
"repository": {
@@ -16,16 +16,13 @@
1616
"ignite ui",
1717
"igniteui",
1818
"angular2",
19+
"angular",
1920
"infragistics",
2021
"jquery widgets",
2122
"jquery controls",
2223
"data visualization",
2324
"data grids"
2425
],
25-
"peerDependencies": {
26-
"@angular/common": "2.0.0",
27-
"@angular/core": "2.0.0"
28-
},
2926
"dependencies": {
3027
"@types/reflect-metadata": "^0.0.5"
3128
}

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<!-- 1. Load libraries -->
1212
<script src="http://code.jquery.com/jquery-1.12.3.js"></script>
13-
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
13+
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
1414
<!-- IE required polyfills, in this exact order -->
1515
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.min.js"></script>
1616
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.20/system-polyfills.js"></script>
@@ -209,6 +209,7 @@ <h2>Samples</h2>
209209
<li><a href="samples/igGrid-ComplexOpts/igGrid-ComplexOpts.html">Complex template options</a></li>
210210
<li><a href="samples/igGrid-HTTPClient/igGrid-HTTPClient.html">Grid with HTTP client</a></li>
211211
<li><a href="samples/igGrid-callingMethods/igGrid-callingMethods.html">Calling API methods</a></li>
212+
<li><a href="samples/igGrid-AoT/igGrid-AoT.html">Grid AoT</a></li>
212213
</ul>
213214
</div>
214215
<a class="btn btn-default" href="samples/igHierarchicalGrid/igHierarchicalGrid.html">igHierarchicalGrid</a>

package.json

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
"url": "https://github.com/IgniteUI/igniteui-angular2.git"
88
},
99
"dependencies": {
10-
"@angular/common": "~4.0.0",
11-
"@angular/compiler": "~4.0.0",
12-
"@angular/core": "~4.0.0",
13-
"@angular/http": "~4.0.0",
14-
"@angular/forms": "~4.0.0",
15-
"@angular/platform-browser": "~4.0.0",
16-
"@angular/platform-browser-dynamic": "~4.0.0",
17-
"@angular/router": "~4.0.0",
18-
"@angular/upgrade": "~4.0.0",
10+
"@angular/common": "~4.0.0",
11+
"@angular/compiler": "~4.0.0",
12+
"@angular/core": "~4.0.0",
13+
"@angular/http": "~4.0.0",
14+
"@angular/forms": "~4.0.0",
15+
"@angular/platform-browser": "~4.0.0",
16+
"@angular/platform-browser-dynamic": "~4.0.0",
17+
"@angular/router": "~4.0.0",
18+
"@angular/upgrade": "~4.0.0",
1919
"angular-in-memory-web-api": "~0.3.0",
2020

2121
"core-js": "^2.4.1",
@@ -28,6 +28,7 @@
2828
"bootstrap": "^3.3.6"
2929
},
3030
"devDependencies": {
31+
"@angular/compiler-cli": "~4.0.0",
3132
"concurrently": "^3.2.0",
3233
"gulp-watch": "^4.3.5",
3334
"jasmine-core": "^2.4.1",
@@ -53,8 +54,10 @@
5354

5455
"watch": "node node_modules/typescript/bin/tsc -w",
5556
"build": "node node_modules/typescript/bin/tsc",
56-
"bundle": "node node_modules/typescript/bin/tsc -d && npm run prepare-dist",
57-
"prepare-dist": "cp src/igniteui.angular2.js dist/npm/index.js && cp src/igniteui.angular2.d.ts dist/npm/index.d.ts && cp src/igniteui.angular2.ts dist/npm/igniteui.angular2.ts && cp src/igniteui.ts dist/npm/ && cp src/igniteui.js dist/npm/ && cp src/igniteui.js.map dist/npm/ && cp src/jquery.d.ts dist/npm/",
57+
"build-aot": "ngc -p tsconfig-aot.json",
58+
"build-aot-samples": "ngc -p tsconfig-aot-samples.json",
59+
"bundle": "npm run build-aot && npm run prepare-dist",
60+
"prepare-dist": "cp src/igniteui.angular2.js dist/npm/index.js && cp src/igniteui.angular2.d.ts dist/npm/index.d.ts && cp src/igniteui.angular2.metadata.json dist/npm/index.metadata.json && cp src/igniteui.angular2.ts dist/npm/igniteui.angular2.ts && cp src/igniteui.ts dist/npm/ && cp src/igniteui.js dist/npm/ && cp src/igniteui.js.map dist/npm/ && cp src/jquery.d.ts dist/npm/",
5861

5962
"pretest": "npm run build",
6063
"test": "karma start tests/karma.conf.js && npm run remap-istanbul",

0 commit comments

Comments
 (0)