2017-11-17 10 views
0

私は私のコンポーネントに特定のライブラリを使用しようとしていますが、私はきちんと角度成分にtypescriptですモジュールをインポート

次のように私のコンポーネントがあり、それを含めてのステップが欠落しているように見えます。問題のライブラリはgeloibs .d.tsファイル

import { Component, OnInit } from '@angular/core'; 
import { StationsService } from '../../../services/stations/stations.service'; 
import { Station } from '../../../classes/station.model'; 
import 'geolib'; 

@Component({ 
    selector: 'app-pollution', 
templateUrl: './pollution.component.html', 
styleUrls: ['./pollution.component.scss'] 
}) 
export class PollutionComponent implements OnInit { 
private markers: Station[]; 

constructor(private stationsService: StationsService) { } 

ngOnInit() { 
    this.stationsService.GetAll().subscribe(
     res => { 
      for (let i of res) { 
       var t = geolib.computeDestinationPoint({ latitude: i.Lat, longitude: i.Long }, 1234, 90); 
      } 
      this.markers = res; 
     } 
    ); 
    } 
} 

geolibある

declare namespace geolib {  
..... 
} 
declare module "geolib" { 
export = geolib; 
} 

ツーリングは文句はありません、すべてのコンパイルが、私は定義されていないgeolibそれを実行するときに、次のようです。

+0

はあなたがgeolibとして「geolib」から*インポートを試してみました。 – bryan60

+0

それはうまくいった!ありがとうございました!答えとして提出し、私はそのようにマークします。 – americanslon

+0

完了、喜んで助けてください – bryan60

答えて

0

この構文を使用し、このように構成モジュールをインポートするには:

import * as geolib from 'geolib'; 
関連する問題