Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typings file for TypeScript & Angular 2 #105

Closed
maddy2get opened this issue Sep 27, 2016 · 6 comments
Closed

Typings file for TypeScript & Angular 2 #105

maddy2get opened this issue Sep 27, 2016 · 6 comments

Comments

@maddy2get
Copy link

Hey there,

I was trying to use this lib on an angular 2 project and just wondering if you would be able to add in typings definitions for this lib? Please see this link for more info: typings/typings#322

Thanks in advance.

@lindell
Copy link
Owner

lindell commented Sep 27, 2016

Sounds like a great initiative. I would gladly accept a pull request 😄

@CooleyGit
Copy link

CooleyGit commented Dec 4, 2016

+1 Would be nice to have a typings definitions.

I am currently using this library on an Ionic 2 project but I had to create a declarations.d.ts file with declare module 'jsbarcode'; "All this does is tell the Typescript compiler that the module is found, and it is an object of any type. This will allow the library to be used freely without the Typescript compiler giving errors." From ionic 2 docs

Basic example below:

import { Component, ViewChild, ElementRef } from '@angular/core';
import JsBarcode from 'jsbarcode';

@Component({
 template: `
     <svg #barcode id="barcode"></svg>`
`})
export class BarcodeEx {
    @ViewChild('barcode') barcode: ElementRef;
    ngAfterViewInit() {
       JsBarcode(this.barcode.nativeElement, '12345');
    }
}

@mhartington
Copy link

Hi there, Ionic member here.

Unless I installed the wrong library (which I'm sure I didn't), this already includes it's own types that are compatible with typescript 2.0.

screen shot 2017-01-05 at 2 04 14 pm

import { Component, ViewChild, ElementRef } from '@angular/core';
import JsBarcode from 'jsbarcode';
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  public picture;
  @ViewChild('barcode') barcode: ElementRef;

  ionViewDidLoad() {
    JsBarcode(this.barcode.nativeElement, '12345');
  }
}

And everything works great.

lindell added a commit that referenced this issue Jan 12, 2017
@lindell
Copy link
Owner

lindell commented Jan 13, 2017

Added it myself now. Could you confirm everything seems like you expected @maddy2get by installing it via.

npm install https://github.com/lindell/JsBarcode

@CooleyGit
Copy link

I just reinstalled on my app works great. Thanks

@lindell lindell closed this as completed Jan 24, 2017
@fahmisaad
Copy link

Can someone teach me on how to convert it to image in ionic. kinda stuck here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants