に設定されているにもかかわらず、未定義です:initialize
でAngular2 - クラスプロパティは、それが私には、次の、非常にシンプルなangular2サービス抱えている
@Injectable()
export class DrawingService {
private _draw:Draw;
constructor(private mapSvc:MapService) {}
initialize(geometry: GeometryType):void {
this._draw = new Draw(this.mapSvc.getMap());
this._draw.on("draw-end", this.addGraphic);
this._draw.activate(geometry);
}
addGraphic(evt):void {
this._draw.deactivate();
}
}
を、私はコールバックとしてメソッドaddGraphic
を設定しています。問題は、addGraphic
メソッドの実行中にthis._draw
が定義されていないことです。
ここで問題は何ですか?
「初期化(geomotry)」はどこから呼び出されますか? – Martin