|
| 1 | +# target-ng-module |
| 2 | + |
| 3 | +## Installation |
| 4 | + |
| 5 | +To install this library, run: |
| 6 | + |
| 7 | +```bash |
| 8 | +$ npm install @adobe/target-ng-module --save |
| 9 | +``` |
| 10 | + |
| 11 | +## Consuming Target library module |
| 12 | + |
| 13 | +Install the library and then from your Angular `AppModule`: |
| 14 | + |
| 15 | +```typescript |
| 16 | +import { BrowserModule } from '@angular/platform-browser'; |
| 17 | +import { NgModule } from '@angular/core'; |
| 18 | + |
| 19 | +import { AppComponent } from './app.component'; |
| 20 | + |
| 21 | +// Import the library |
| 22 | +import { TargetModule } from '@adobe/target-ng-module'; |
| 23 | + |
| 24 | +@NgModule({ |
| 25 | + declarations: [ |
| 26 | + AppComponent |
| 27 | + ], |
| 28 | + imports: [ |
| 29 | + BrowserModule, |
| 30 | + |
| 31 | + // Specify Target library as an import |
| 32 | + TargetModule |
| 33 | + ], |
| 34 | + providers: [], |
| 35 | + bootstrap: [AppComponent] |
| 36 | +}) |
| 37 | +export class AppModule { } |
| 38 | +``` |
| 39 | + |
| 40 | +Once the library is imported, you can use Target **mbox** directive in your Angular application: |
| 41 | + |
| 42 | +```javascript |
| 43 | +// Specify Target options in your app.component.ts |
| 44 | +@Component({ |
| 45 | + selector: 'app-root', |
| 46 | + templateUrl: './app.component.html' |
| 47 | +}) |
| 48 | +export class AppComponent { |
| 49 | + targetOpts = { |
| 50 | + mbox: 'simpleDirective' |
| 51 | + }; |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +```xml |
| 56 | +<!-- You can now use Target mbox directive in app.component.html --> |
| 57 | +<h1> |
| 58 | + {{title}} |
| 59 | +</h1> |
| 60 | +<div [mbox]="targetOpts"> |
| 61 | + Default content |
| 62 | +</div> |
| 63 | +``` |
| 64 | + |
| 65 | +## Options |
| 66 | + |
| 67 | +> The following Target options can be set on the **mbox** directive: |
| 68 | +
|
| 69 | +Key | Type | Mandatory | Description |
| 70 | +--- | ---- | --------- | ----------- |
| 71 | +`mbox` | String | Yes | mbox name. It is mandatory if you want to track clicks. If not provided, an error will be logged and tracking event won't be attached. |
| 72 | +`params` | Object | No | mbox parameters - an object of key-value pairs. |
| 73 | +`timeout` | Number | No | timeout in milliseconds. If not specified, default adobe.target will be used. |
| 74 | + |
| 75 | +## Development |
| 76 | + |
| 77 | +To generate all `*.js`, `*.d.ts` and `*.metadata.json` files: |
| 78 | + |
| 79 | +```bash |
| 80 | +$ npm run build |
| 81 | +``` |
| 82 | + |
| 83 | +To lint all `*.ts` files: |
| 84 | + |
| 85 | +```bash |
| 86 | +$ npm run lint |
| 87 | +``` |
| 88 | + |
| 89 | +To publish built package, login to NPM and then publish with: |
| 90 | +```bash |
| 91 | +$ npm publish dist |
| 92 | +``` |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +Apache-2.0 © [Adobe Systems Inc.](mailto:anischev@adobe.com) |
0 commit comments