私は、typescriptプロジェクトとより具体的な角度アプリケーションを持っています。新しいクラスのメソッド内でメソッドを作成します。
私はTestという名前のクラスを持っています(角度のコンポーネントを想定することができます)、通常はthis.http( '/ endpoint')のように使用されるhttpサービスにアクセスできますsubscribe(response => {}) ;
私はいくつかのロジックを間に追加し、別々のメソッドに分割する必要があります(コードは私の例より少し複雑です)。 }
iはthis.http.get( '/エンドポイント')を呼び出す
export class Test {
init() {
this.http.get('/endpoint').map(this.transform);
}
transform(data) {
// more logic here in isolated scope
this.accessOutside(data); // I cannot access this method, isolated scope.
// How to break down some logic into separate methods to access them
// or how to create it new method within method?
return data
}
accessOutside(data) {
// more logic
}
。マップ(this.transform)私の方法は、単離され、テストクラス内の他のメソッドへのアクセスを持っていません "変換" 、どのようにそれにアクセスする方法またはどのように変換メソッド内のメソッドを作成する?
ではありません。まさに私が望むもの。ありがとうございました! –