You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>A proxy, in its most general form, is a class functioning as an interface to something else. The proxy could interface to anything: a network connection, a large object in memory, a file, or some other resource that is expensive or impossible to duplicate.
`console.log`would outputs an empty object. Since the AJAX request, which happens behind the scene, when `User.get`is invoked, is asynchronous, we don't have the actual user when `console.log`is called. Just after `User.get`makes the GET request it returns an empty object and keeps reference to it. We can think of this object as virtual proxy (a simple placeholder), which would be populated with the actual data once the client receives response by the server.
How does this works with AngularJS? Well, lets consider the following snippet:
529
+
これはAngularJSでどのように使われるのでしょうか? 次のスニペットを考えてみましょう:
530
530
531
531
```JavaScript
532
532
functionMainCtrl($scope, $resource) {
@@ -538,7 +538,8 @@ function MainCtrl($scope, $resource) {
538
538
```html
539
539
<spanng-bind="user.name"></span>
540
540
```
541
-
Initially when the snippet above executes, the property `user` of the `$scope` object will be with value an empty object (`{}`), which means that `user.name` will be undefined and nothing will be rendered. Internally AngularJS will keep reference to this empty object. Once the server returns response for the get request, AngularJS will populate the object with the data, received from the server. During the next `$digest` loop AngularJS will detect change in `$scope.user`, which will lead to update of the view.
0 commit comments