私はこのようなプロミスチェーンを持っています...
this.getFile(fileId).then(updateFile).then(displayAllDoneMessage);
wheregetFile()
とupdateFile()
each を使用ngResource
して適切な JSON 呼び出しを作成し、$resource.$promise
.
$scope
チェーンは正常に起動しますが、内部からのアクセスに問題がありますupdateFile
だからgetFile()
私は持っています
// this works
this.status.text = "fetching file"
しかし、updateFile()
私は持っています
// this fails at runtime because "this" is not $scope
this.status.text = "updating file"
私は何を間違っていますか、または$scope
内で利用できるようにするために何をする必要がありますupdateFile()
か?
重要な場合に備えて、TypeScript を使用していることを追加する必要があります。