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
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -504,7 +504,7 @@ We can distinguish three different types of proxy:
504
504
- Remote Proxy
505
505
- Protection Proxy
506
506
507
-
In this sub-chapter we are going to take a look at AngularJS implementation of Virtual Proxy.
507
+
In this sub-chapter we are going to take a look at AngularJS' implementation of Virtual Proxy.
508
508
509
509
In the snippet bellow, there is a call to the `get` method of `$resource` instance, called `User`:
510
510
@@ -514,7 +514,7 @@ var User = $resource('/users/:id'),
514
514
console.log(user); //{}
515
515
```
516
516
517
-
`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, which would be populated with data once the client receives response by the server.
517
+
`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.
518
518
519
519
How does this works with AngularJS? Well, lets consider the following snippet:
520
520
@@ -528,7 +528,7 @@ function MainCtrl($scope, $resource) {
528
528
```html
529
529
<spanng-bind="user.name"></span>
530
530
```
531
-
Initially when the snippet above executes, the property `user` of the `$scope` object will be with value an empty object (`{}`). Internally AngularJS will keep reference to this empty object. When the dirty checking loop detects change in the `$scope`, AngularJS will try to set `user.name`as value of the span. Since the value is `undefined` the span will stay empty. 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.
531
+
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