Skip to content

Commit

Permalink
fix(example): add example for formatter (#293)
Browse files Browse the repository at this point in the history
* add example for formatter to component.ts

* add preview to html

* add example to readme

* Restyled by prettier-markdown (#294)

closes #292

Co-authored-by: Restyled.io <commits@restyled.io>

Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
3 people authored May 27, 2020
1 parent afd7a2d commit f5dffe0
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 21 deletions.
78 changes: 58 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
[![codecov](https://codecov.io/gh/DanielHabenicht/ngx-vcard/branch/master/graph/badge.svg)](https://codecov.io/gh/DanielHabenicht/ngx-vcard)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FDanielHabenicht%2Fngx-vcard.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FDanielHabenicht%2Fngx-vcard?ref=badge_shield)


# ngx-vcard

Almost fully RFC compliant vCard Formatter, that also can download the generated vCard.
Outputs VCard version 4.
Maybe other version will be supported.
Almost fully RFC compliant vCard Formatter, that also can download the generated
vCard. Outputs VCard version 4. Maybe other version will be supported.

If you want to have another Property, please open up an issue or even better provide a PR. ;)
If you want to have another Property, please open up an issue or even better
provide a PR. ;)

## Installation

Expand All @@ -23,10 +22,10 @@ If you want to have another Property, please open up an issue or even better pro
2. Import in app.module.ts:

```typescript
import { NgxVcardModule } from 'ngx-vcard';
import { NgxVcardModule } from "ngx-vcard";
@NgModule({
imports: [NgxVcardModule]
imports: [NgxVcardModule],
})
export class AppModule {}
```
Expand All @@ -39,39 +38,78 @@ If you want to have another Property, please open up an issue or even better pro
```typescript
/* example.component.ts */
import { Component } from '@angular/core';
import { VCard } from 'ngx-vcard';
import { Component } from "@angular/core";
import { VCard } from "ngx-vcard";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
})
export class AppComponent {
public vCard: VCard = {
name: {
firstNames: 'John',
lastNames: 'Doe'
}
firstNames: "John",
lastNames: "Doe",
},
};
}
```
```html
<!-- example.component.html -->
<div>
<button id="downloadButton" [vcdDownloadVCard]="vCard">Download VCard!</button>
<button id="downloadButton" [vcdDownloadVCard]="vCard">
Download VCard!
</button>
</div>
```
### Use as Formatter
- TODO: Add .ts File example
[Look here for a Stackblitz Example](https://stackblitz.com/github/DanielHabenicht/ngx-vcard)
## Mentions
```typescript
/* example.component.ts */
import { Component } from "@angular/core";
import { VCardFormatter, VCard } from "ngx-vcard";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
})
export class AppComponent {
public vCard: VCard = {
name: {
firstNames: "John",
lastNames: "Doe",
},
};
This project is heavily inspired from the [vCards-js](https://github.com/enesser/vCards-js) Package from Eric J Nesser.
public vCardString = VCardFormatter.getVCardAsString(this.vCard);
public ngOnInit() {
console.log(this.vCardString);
}
}
```
```html
<!-- example.component.html -->
<p>
VCard String:
</p>
<p>
{{vCardString}}
</p>
```
## Mentions
This project is heavily inspired from the
[vCards-js](https://github.com/enesser/vCards-js) Package from Eric J Nesser.
## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FDanielHabenicht%2Fngx-vcard.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FDanielHabenicht%2Fngx-vcard?ref=badge_large)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FDanielHabenicht%2Fngx-vcard.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FDanielHabenicht%2Fngx-vcard?ref=badge_large)
8 changes: 7 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<div>
<button id="downloadButton" [vcdDownloadVCard]="vCard" [encoding]="vCardEncoding.none">Download VCard!</button>
</div>
</div>
<p>
VCard String Preview:
</p>
<p>
{{vCardString}}
</p>
2 changes: 2 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { VCard } from 'ngx-vcard';
import { VCardEncoding } from 'ngx-vcard';
import { VCardFormatter } from 'ngx-vcard';

@Component({
selector: 'app-root',
Expand All @@ -10,4 +11,5 @@ import { VCardEncoding } from 'ngx-vcard';
export class AppComponent {
public vCardEncoding: typeof VCardEncoding = VCardEncoding;
public vCard: VCard = { name: { firstNames: 'John', lastNames: 'Doe' } };
public vCardString = VCardFormatter.getVCardAsString(this.vCard)
}

0 comments on commit f5dffe0

Please sign in to comment.