|
| 1 | +import { Meta } from "@storybook/addon-docs"; |
| 2 | + |
| 3 | +<Meta title="Docs/Framework Integration/Angular" /> |
| 4 | + |
| 5 | +# Integrate with Angular |
| 6 | + |
| 7 | +We set up a demo project with the Angular CLI to show you how to integrate the components into a freshly generated Angular project. |
| 8 | +These instructions are based on `angular@12.0.0` and [`angular-cli@12.0.0`](https://cli.angular.io/). |
| 9 | + |
| 10 | +## Step 1: Install `@inovex.de/elements-angular` |
| 11 | + |
| 12 | +We provide an integration layer package for Angular so you can use the inovex Elements as a native Angular library with full type support. |
| 13 | + |
| 14 | +**Using Angular CLI (recommended):** |
| 15 | + |
| 16 | +```bash |
| 17 | +ng add @inovex.de/elements-angular |
| 18 | +``` |
| 19 | + |
| 20 | +> The `ino-icons` are added to your project automatically when you use the Angular CLI. |
| 21 | +
|
| 22 | + |
| 23 | +**Using npm:** |
| 24 | + |
| 25 | +```shell |
| 26 | +npm i @inovex.de/elements-angular |
| 27 | +``` |
| 28 | + |
| 29 | + |
| 30 | +## Step 2: Update `angular.json` (npm / yarn only) |
| 31 | + |
| 32 | +> This step is only necessary if you installed the Angular wrapper via npm or yarn. |
| 33 | +
|
| 34 | +Add the following entry to the build assets |
| 35 | +(`projects.<your-project-name>.architect.build.options.assets`) **and** to the |
| 36 | +test assets (`projects.<your-project-name>.architect.test.options.assets`): |
| 37 | + |
| 38 | +```json |
| 39 | +// ... |
| 40 | +{ |
| 41 | + "glob": "**/*", |
| 42 | + "input": "node_modules/@inovex.de/elements/dist/inovex-elements/ino-icon", |
| 43 | + "output": "/ino-icon" |
| 44 | +} |
| 45 | +// ... |
| 46 | +``` |
| 47 | + |
| 48 | +## Step 3: Import `InoElementsModule` |
| 49 | + |
| 50 | +The Angular wrapper exposes all `@Input` properties and `@Output` events as |
| 51 | +typed Angular directives, giving you full IDE auto-completion and compiler |
| 52 | +checks. |
| 53 | + |
| 54 | +Import `InoElementsModule` into your app module (or any shared module): |
| 55 | + |
| 56 | +1. Import the module from `@inovex.de/elements-angular` |
| 57 | +2. Add it to your `imports` array — you can optionally pass an `InoElementsConfig` |
| 58 | +3. Add `CUSTOM_ELEMENTS_SCHEMA` to the `schemas` array |
| 59 | + |
| 60 | +```typescript |
| 61 | +import { BrowserModule } from '@angular/platform-browser'; |
| 62 | +import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; |
| 63 | +import { InoElementsModule } from '@inovex.de/elements-angular'; |
| 64 | +import { AppComponent } from './app.component'; |
| 65 | + |
| 66 | +@NgModule({ |
| 67 | + declarations: [AppComponent], |
| 68 | + imports: [ |
| 69 | + BrowserModule, |
| 70 | + InoElementsModule.forRoot({}), |
| 71 | + ], |
| 72 | + providers: [], |
| 73 | + bootstrap: [AppComponent], |
| 74 | + schemas: [CUSTOM_ELEMENTS_SCHEMA], |
| 75 | +}) |
| 76 | +export class AppModule {} |
| 77 | +``` |
| 78 | + |
| 79 | +> **Tip:** If you have multiple feature modules, import `InoElementsModule` once |
| 80 | +> in a shared module and re-export it from there. |
| 81 | +
|
| 82 | +## Use the Components |
| 83 | + |
| 84 | +That's it — you are now ready to use any inovex Elements component in your Angular templates! |
| 85 | + |
0 commit comments