Skip to content

Commit

Permalink
Merge pull request #27 from XDex/TNT-27423
Browse files Browse the repository at this point in the history
TNT-27423 Angular 2 support for AT.js
  • Loading branch information
XDex authored Jul 31, 2017
2 parents a3e9052 + 2a059fc commit 9db27ec
Show file tree
Hide file tree
Showing 17 changed files with 7,583 additions and 0 deletions.
32 changes: 32 additions & 0 deletions angular2/module/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Node
node_modules/*
npm-debug.log

# TypeScript
src/*.js
src/*.map
src/*.d.ts

# JetBrains
.idea
.project
.settings
.idea/*
*.iml

# VS Code
.vscode/*

# Windows
Thumbs.db
Desktop.ini

# Mac
.DS_Store
**/.DS_Store

# Ngc generated files
**/*.ngfactory.ts

# Build files
dist/*
34 changes: 34 additions & 0 deletions angular2/module/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Node
node_modules/*
npm-debug.log
docs/*
# DO NOT IGNORE TYPESCRIPT FILES FOR NPM
# TypeScript
# *.js
# *.map
# *.d.ts

# JetBrains
.idea
.project
.settings
.idea/*
*.iml

# VS Code
.vscode/*

# Windows
Thumbs.db
Desktop.ini

# Mac
.DS_Store
**/.DS_Store

# Ngc generated files
**/*.ngfactory.ts

# Library files
src/*
build/*
4 changes: 4 additions & 0 deletions angular2/module/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: node_js
sudo: false
node_js:
- '4.2.1'
7 changes: 7 additions & 0 deletions angular2/module/.yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"generator-angular2-library": {
"promptValues": {
"gitRepositoryUrl": "https://github.com/Adobe-Marketing-Cloud/target-atjs-extensions"
}
}
}
96 changes: 96 additions & 0 deletions angular2/module/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# target-ng-module

## Installation

To install this library, run:

```bash
$ npm install @adobe/target-ng-module --save
```

## Consuming Target library module

Install the library and then from your Angular `AppModule`:

```typescript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import the library
import { TargetModule } from '@adobe/target-ng-module';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,

// Specify Target library as an import
TargetModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
```

Once the library is imported, you can use Target **mbox** directive in your Angular application:

```javascript
// Specify Target options in your app.component.ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
targetOpts = {
mbox: 'simpleDirective'
};
}
```

```xml
<!-- You can now use Target mbox directive in app.component.html -->
<h1>
{{title}}
</h1>
<div [mbox]="targetOpts">
Default content
</div>
```

## Options

> The following Target options can be set on the **mbox** directive:
Key | Type | Mandatory | Description
--- | ---- | --------- | -----------
`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.
`params` | Object | No | mbox parameters - an object of key-value pairs.
`timeout` | Number | No | timeout in milliseconds. If not specified, default adobe.target will be used.

## Development

To generate all `*.js`, `*.d.ts` and `*.metadata.json` files:

```bash
$ npm run build
```

To lint all `*.ts` files:

```bash
$ npm run lint
```

To publish built package, login to NPM and then publish with:
```bash
$ npm publish dist
```

## License

Apache-2.0 © [Adobe Systems Inc.](mailto:[email protected])
Loading

0 comments on commit 9db27ec

Please sign in to comment.