Skip to content

Commit 9db27ec

Browse files
authored
Merge pull request #27 from XDex/TNT-27423
TNT-27423 Angular 2 support for AT.js
2 parents a3e9052 + 2a059fc commit 9db27ec

17 files changed

+7583
-0
lines changed

angular2/module/.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Node
2+
node_modules/*
3+
npm-debug.log
4+
5+
# TypeScript
6+
src/*.js
7+
src/*.map
8+
src/*.d.ts
9+
10+
# JetBrains
11+
.idea
12+
.project
13+
.settings
14+
.idea/*
15+
*.iml
16+
17+
# VS Code
18+
.vscode/*
19+
20+
# Windows
21+
Thumbs.db
22+
Desktop.ini
23+
24+
# Mac
25+
.DS_Store
26+
**/.DS_Store
27+
28+
# Ngc generated files
29+
**/*.ngfactory.ts
30+
31+
# Build files
32+
dist/*

angular2/module/.npmignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Node
2+
node_modules/*
3+
npm-debug.log
4+
docs/*
5+
# DO NOT IGNORE TYPESCRIPT FILES FOR NPM
6+
# TypeScript
7+
# *.js
8+
# *.map
9+
# *.d.ts
10+
11+
# JetBrains
12+
.idea
13+
.project
14+
.settings
15+
.idea/*
16+
*.iml
17+
18+
# VS Code
19+
.vscode/*
20+
21+
# Windows
22+
Thumbs.db
23+
Desktop.ini
24+
25+
# Mac
26+
.DS_Store
27+
**/.DS_Store
28+
29+
# Ngc generated files
30+
**/*.ngfactory.ts
31+
32+
# Library files
33+
src/*
34+
build/*

angular2/module/.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: node_js
2+
sudo: false
3+
node_js:
4+
- '4.2.1'

angular2/module/.yo-rc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"generator-angular2-library": {
3+
"promptValues": {
4+
"gitRepositoryUrl": "https://github.com/Adobe-Marketing-Cloud/target-atjs-extensions"
5+
}
6+
}
7+
}

angular2/module/README.MD

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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

Comments
 (0)