利用AngularJS框架实践各种设计模式:AngularJS in Patterns。
jopen
10年前
利用AngularJS框架实践各种设计模式:AngularJS in Patterns。
Proxy
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.
We can distinguish three different types of proxy:
- Virtual Proxy
- Remote Proxy
- Protection Proxy
In this sub-chapter we are going to take a look at AngularJS' implementation of Virtual Proxy.
In the snippet bellow, there is a call to the get
method of $resource
instance, called User
:
var User = $resource('/users/:id'), user = User.get({ id: 42 }); console.log(user); //{}