angular.js - angularJS official website phonecat example, how to get the phonelist after registering the Phone service?
PHP中文网
PHP中文网 2017-05-15 16:53:45
0
1
640

I am learning AngularJS recently. In Step-11, I registered the Phone service instead of sending an http request in the controller to obtain phones/:phoneId.json. But I don’t know why Phone.query() in PhoneListCtrl can get the phonelist.

I hope someone can give me an answer.

The following is the code modification of Step-11: https://github.com/angular/angular-phonecat/compare/step-10...step-11

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
巴扎黑

The reason is this sentence:

javascriptreturn $resource('phones/:phoneId.json', {}, {
    query: {method:'GET', params:{phoneId:'phones'}, isArray:true}
});

phoneService 返回了一个 $resource,这个 $resource 注册了一个 actionquery,该方法访问的路径、HTTP 方法、参数、返回数据类型都在上述代码里,最终会调用底层的 $http The service initiates a request to get the data.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template