简体   繁体   中英

'this' reference in angular asynchronous calls vs react and node asynchronous calls

Why does this in angular's this.http.subscribe body references the current component while this in react or node's nested asynchronous callbacks references the http request itself? What can i do to achieve the angular pattern?

To achieve the angular pattern you can add a that = this; before the subscribe (in the method body). Then reference it in the subscribe.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM