ngx-vcard
TypeScript icon, indicating that this package has built-in type declarations

4.1.19 • Public • Published

npm version Build Status Commitizen friendly Renovate enabled codecov FOSSA Status

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.

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

Open in Gitpod

Installation

  1. Install from npm

    $ npm install ngx-vcard --save
  2. Import in app.module.ts:

    import { NgxVcardModule } from "ngx-vcard";
    
    @NgModule({
      imports: [NgxVcardModule],
    })
    export class AppModule {}

How to use

Use as Directive

Look here for a Stackblitz Example

/* example.component.ts */
import { Component } from "@angular/core";
import { 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",
    },
  };
  public generateVCardOnTheFly = (): VCard => {
    // TODO: Generate the VCard before Download
    return {
      name: { firstNames: "John", lastNames: "Doe", addtionalNames: "Auto" },
    };
  };
}
<!-- example.component.html -->
<div>
  <!-- Normal -->
  <button id="downloadButtonNormal" [vcdDownloadVCard]="vCard">
    Download VCard!
  </button>
  <!-- Generate VCard only on Click -->
  <button
    id="downloadButtonFunction"
    vcdDownloadVCard
    [generateVCardFunction]="generateVCardOnTheFly"
  >
    Download generated VCard!
  </button>
</div>

Use as Formatter

Look here for a Stackblitz Example

/* 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",
    },
  };

  public vCardString = VCardFormatter.getVCardAsString(this.vCard);

  public ngOnInit() {
    console.log(this.vCardString);
  }
}
<!-- example.component.html -->
<p>VCard String:</p>
<p>{{vCardString}}</p>

Mentions

This project is heavily inspired from the vCards-js Package from Eric J Nesser.

RFC

License

FOSSA Status

Readme

Keywords

Package Sidebar

Install

npm i ngx-vcard

Weekly Downloads

870

Version

4.1.19

License

MIT

Unpacked Size

222 kB

Total Files

25

Last publish

Collaborators

  • danielhabenicht