Search code examples
meteorangularangular2-meteor

How to add correctly use Meteor package in a angular2-meteor project?


I am writing an angular2-meteor program.

When I am using urigo:angular2-meteor package, I add reference path like this:

/// <reference path="../typings/angular2-meteor.d.ts" />

The question is: can I use other normal meteor packages in a angular2-meteor project? Or I can only use some packages written for angular2-meteor specifically.

For example, if I want to use yuukan:streamy, how can I use it correctly? Right now, I have one line code

Streamy.broadcast('hello', {data: 'world!'});

When I compile it, it shows: Cannot find name 'Streamy'.

Thanks!


Solution

  • you can use all the libraries from meteor.

    you will have 2 choices.

    1. find the streamy definition file (streamy.d.ts) if it exists. This will give you autocompletion and compile errors if you misuse streamy functions.
    2. If you dont find a definition file than just add declare var Streamy at the top of the file you want to use it. The library is already there if you add it via atmosphere. But typescript does not know about it. By declaring the variable you tell typescript that this exists and it wont complain when compiling.