You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use the `igniteui.angular2.js` to taka advantage from the [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).
3
+
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).
4
4
5
-
#Requirements
5
+
#Requirements
6
6
7
7
-[jQuery](http://www.jquery.com) v1.9.1 and later
8
8
-[jQuery UI](http://www.jqueryui.com) v1.9.0 and later
9
-
-[AngularJS 2](https://angular.io/) v2.0 beta and later
9
+
-[Angular](https://angular.io/) v2.0 beta and later
10
10
-[Ignite UI](http://www.igniteui.com) 15.2 and later
11
11
12
-
#Getting Started
12
+
# Running the samples
13
+
To run the samples, you need [Node.js](http://nodejs.org/) installed on your machine.
14
+
Afterwards, from your terminal run the following commands:
In an Angular 2 application, Ignite UI controls support markup initialization which is done by using custom tags.
24
+
In an Angular application, Ignite UI controls support markup initialization which is done by using custom tags.
16
25
17
26
### Custom tags
18
27
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.
@@ -51,8 +60,7 @@ There are two mandatory attributes that need to be set to an Ignite UI control c
51
60
selector: 'my-app',
52
61
template: `<ig-grid
53
62
[(options)]="gridOptions"
54
-
[(widgetId)]='id'></ig-grid>`,
55
-
directives: [IgGridComponent]
63
+
[(widgetId)]='id'></ig-grid>`
56
64
})
57
65
export class AppComponent {
58
66
private gridOptions: IgGrid;
@@ -91,8 +99,7 @@ when there are overlapping properties. Also changing top-level attribute will ap
91
99
[height]='h'
92
100
[autoGenerateColumns]='true'
93
101
>
94
-
</ig-grid>`,
95
-
directives: [IgGridComponent]
102
+
</ig-grid>`
96
103
})
97
104
export class AppComponent {
98
105
private id: string;
@@ -110,6 +117,94 @@ when there are overlapping properties. Also changing top-level attribute will ap
110
117
}
111
118
}
112
119
120
+
### Other custom tags
121
+
122
+
There are two custom tags `<column>` and `<features>` that are used in igGrid/igTreeGrid/igHierarchicalGrid to configure the `columns` and `features` options accordingly.
In order to change the more options at once (or recreate the component with another set of options), the new configuration can be applied to the `options` property.
167
+
168
+
#### Example:
169
+
170
+
@Component({
171
+
selector: 'my-app',
172
+
template: `<ig-grid
173
+
[(options)]="gridOptions"
174
+
[(widgetId)]='id'></ig-grid>`
175
+
})
176
+
export class AppComponent {
177
+
private gridOptions: IgGrid;
178
+
private id: string;
179
+
private data: any;
180
+
181
+
constructor() {
182
+
this.data = Northwind.getData();
183
+
this.id ='grid1';
184
+
this.gridOptions = {
185
+
dataSource: this.data,
186
+
width: "100%",
187
+
height: "400px",
188
+
autoGenerateColumns: true
189
+
};
190
+
}
191
+
192
+
recreateGrid() {
193
+
this.gridOptions = {
194
+
dataSource: Northwind.getAnotherData(),
195
+
width: "700px",
196
+
autoGenerateColumns: true,
197
+
features: [
198
+
{ name: "Paging" }
199
+
]
200
+
};
201
+
}
202
+
}
203
+
204
+
In this example `options` attribute points to `gridOptions` and changing in reference will destroy the grid, combine the old options with new ones and create the grid with the combined options.
205
+
Also note that the new grid will have height of 400px, even though it's not defined into the new options, because of the combination with new options.
206
+
If disabling an option is required set it to `null`, `undefined`, `[]` or `{}`.
207
+
113
208
### Handling events
114
209
115
210
Binding to control events is achieved by assigning attributes where the name of the attribute is the name of the control's event name surrounded by parenthesis and the value is the name of the event handler.
@@ -122,15 +217,13 @@ Binding to control events is achieved by assigning attributes where the name of
@@ -162,8 +255,7 @@ Binding to igGrid* feature events is done in the control's configuration code.
162
255
selector: 'my-app',
163
256
template: `<ig-grid
164
257
[(options)]="gridOptions"
165
-
[(widgetId)]='id'></ig-grid>`,
166
-
directives: [IgGridComponent]
258
+
[(widgetId)]='id'></ig-grid>`
167
259
})
168
260
export class AppComponent {
169
261
private gridOptions: IgGrid;
@@ -193,6 +285,118 @@ Binding to igGrid* feature events is done in the control's configuration code.
193
285
194
286
In this example igGridFiltering `dataFiltered` event is handled in the application component class.
195
287
288
+
## Calling Component methods
289
+
290
+
Component methods can be called by accessing the component from the view. For example:
291
+
292
+
@Component({
293
+
selector: 'my-app',
294
+
template: '<ig-grid #grid1
295
+
[(options)]="gridOptions">
296
+
<features>
297
+
<paging [pageSize]="'2'"></paging>
298
+
</features>
299
+
</ig-grid>'
300
+
})
301
+
export class AppComponent {
302
+
private gridOptions: IgGrid;
303
+
@ViewChild("grid1") myGrid: IgGridComponent;
304
+
private id: string;
305
+
constructor() { ... }
306
+
307
+
ngAfterViewInit() {
308
+
//call grid method
309
+
var cell = this.myGrid.cellById(1, "Name");
310
+
//call grid paging method
311
+
this.myGrid.featuresList.paging.pageIndex(2);
312
+
}
313
+
}
314
+
315
+
## Using Ignite UI Angular Components inside AOT app
316
+
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.
317
+
318
+
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.
319
+
First we need to install the required packages:
320
+
-`npm install ignite-ui`
321
+
-`npm install igniteui-angular2`
322
+
-`npm install jquery-ui-bundle`
323
+
324
+
**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
325
+
326
+
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:
In addition, at the end import the IgniteUIModule:
336
+
337
+
import { IgniteUIModule } from 'igniteui-angular2';
338
+
@NgModule({
339
+
imports: [ BrowserModule, IgniteUIModule ],
340
+
…
341
+
})
342
+
export class AppModule {}
343
+
344
+
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.
345
+
Open rollup-config.js, include igniteui-angular2 to `commonjs` plugin and add `namedExport` for jquery:
Additional plugin rollup-plugin-replace should be installed
357
+
`npm install rollup-plugin-replace` in order to fix the offline compilation of Ignite UI util module.
358
+
`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).
359
+
360
+
replace({
361
+
// this is undefined for the specified context, so replace it with window to access Class
At the end, apply Ignite UI styling. To achieve this, postcss plugin should be installed
382
+
`npm install rollup-plugin-postcss`
383
+
384
+
Open rollup-config.js file and import postcss:
385
+
386
+
import postcss from 'rollup-plugin-postcss'
387
+
…
388
+
postcss({
389
+
extensions: ['.css']
390
+
}),
391
+
392
+
393
+
[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:
394
+
1. npm install
395
+
2. npm run build:aot
396
+
3. npm run serve
397
+
398
+
399
+
196
400
## Two-way Data Binding
197
401
The following controls currently support two-way data binding:
198
402
@@ -203,9 +407,22 @@ The following controls currently support two-way data binding:
203
407
5. igEditors
204
408
6. igTree
205
409
410
+
## Running tests
411
+
412
+
The command for running the tests is:
413
+
414
+
npm test
415
+
416
+
After that, if all tests successfully passed a code coverage for the `igniteui.angular2.ts` filse will be generated under the `./coverage` folder.
417
+
418
+
To see the code coverage you can open one of the html files under `./coverage/html-report/src`.
419
+
420
+
**Note:** The code coverage is actually being generated on the `igniteui.angular2.js` file (comes from compilation of the source .ts file). That coverage is saved under the `coverage/karma-tmp` folder.
421
+
Since we need the code coverage of the `igniteui.angular2.js` file itself, we use the remap-istanbul module to remap the report from the .js file to the .ts file and save it under the `coverage/html-report` and `coverage/lcov.info`.
[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.
0 commit comments