Skip to content

Commit 119fab1

Browse files
viterobkdxbykov
authored andcommitted
Add the "Add DevExtreme to Ionic 2 Application" guide (#372)
1 parent b69d7a0 commit 119fab1

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ The further configuration steps depend on which build tool, bundler or module lo
101101
* [Configuring Angular CLI](https://github.com/DevExpress/devextreme-angular/blob/master/docs/using-angular-cli.md#configuration)
102102
* [Configuring Webpack](https://github.com/DevExpress/devextreme-angular/blob/master/docs/using-webpack.md#configuration)
103103
* [Configuring Rollup](https://github.com/DevExpress/devextreme-angular/blob/master/docs/using-rollup.md#configuration)
104+
* [Configuring Ionic 2](https://github.com/DevExpress/devextreme-angular/blob/master/docs/using-ionic2.md#configuration)
104105

105106

106107
### <a name="create-application"></a>Create a new Angular 2 Application ###
@@ -111,6 +112,7 @@ Depending on your requirements you can choose one of the following ways to start
111112
* [Start with Angular CLI](https://github.com/DevExpress/devextreme-angular/blob/master/docs/using-angular-cli.md)
112113
* [Start with Webpack](https://github.com/DevExpress/devextreme-angular/blob/master/docs/using-webpack.md)
113114
* [Start with Rollup](https://github.com/DevExpress/devextreme-angular/blob/master/docs/using-rollup.md)
115+
* [Start with Ionic 2](https://github.com/DevExpress/devextreme-angular/blob/master/docs/using-ionic2.md)
114116

115117
### <a name="running-examples"></a>Running the Local Examples ###
116118

docs/using-ionic2.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Using the DevExtreme Angular 2 Integration with Ionic 2
2+
3+
## Create an Application
4+
5+
Create an Ionic 2 application as described in the [Ionic 2 Tutorial](http://ionicframework.com/docs/v2/getting-started/tutorial/).
6+
7+
## Install DevExtreme Angular 2 Integration
8+
9+
Once the application is created, install DevExtreme Angular 2 integration npm package. Run the following command in the command prompt.
10+
11+
```
12+
npm install --save devextreme devextreme-angular
13+
```
14+
15+
## <a name="configuration"></a>Configure Ionic 2 for DevExtreme
16+
17+
To use DevExtreme within the Ionic 2 application, import the required separate modules or entire DevExtreme to this application within the "src\app\app.module.ts" file.
18+
19+
```
20+
//Imports a separate module
21+
import { DxButtonModule } from 'devextreme-angular/ui/button';
22+
23+
//Imports the entire DevExtreme
24+
import { DevExtremeModule } from 'devextreme-angular';
25+
```
26+
27+
Add the imported modules to application imports:
28+
29+
```
30+
@NgModule({
31+
...
32+
imports: [
33+
...
34+
DevExtremeModule,
35+
...
36+
]
37+
})
38+
```
39+
40+
## Copy DevExtreme Stylesheets
41+
42+
DevExtreme style sheets are stored in the "node-modules\devextreme\dist\css" folder. You should copy them to the "www\assets\css" folder. You can do it manually, or use [ionic build tools](https://ionicframework.com/docs/v2/resources/app-scripts/) to copy style sheets during the build process. In the second case, copy the "copy.config.js" file from the [Ionic repository](https://github.com/driftyco/ionic-app-scripts/blob/master/config/copy.config.js) to the application root folder.
43+
44+
Add the following item to the "copy" configuration.
45+
46+
```
47+
module.exports = {
48+
. . .
49+
copyStyleSheets: {
50+
src: ['{{ROOT}}/node_modules/devextreme/dist/css/**/*'],
51+
dest: '{{WWW}}/assets/css'
52+
}
53+
}
54+
```
55+
56+
Reference the created config within the package.json file by adding the "config" section.
57+
58+
```
59+
"config" : {
60+
"ionic_copy": "./copy.config.js"
61+
},
62+
```
63+
64+
Add links to the required stylesheets to the head section of the "src\index.html" file.
65+
66+
```
67+
<link href="assets/css/dx.common.css" rel="stylesheet">
68+
<link href="assets/css/dx.light.css" rel="stylesheet">
69+
```
70+
71+
## Add a DevExtreme Component
72+
73+
After you have performed all steps described above, you can use DevExtreme controls on application views. To try how it works, add a button widget to the "src\pages\hello-ionic\hello-ionic.html" file.
74+
75+
```
76+
. . .
77+
<ion-content padding>
78+
<h3>Welcome to your first Ionic app!</h3>
79+
<dx-button text="Hello world"></dx-button>
80+
. . .
81+
```
82+
83+
For more information on working with DevExtreme controls in Angular 2 approach, refer to the [DevExtreme-Angular library description](https://github.com/DevExpress/devextreme-angular).
84+
85+
## Run the Application
86+
87+
Run the app using the following command
88+
89+
```
90+
ionic serve
91+
```

0 commit comments

Comments
 (0)