V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
CareiOS
V2EX  ›  Node.js

一篇不错的教程,分享给大家

  •  
  •   CareiOS · Jun 7, 2016 · 3479 views
    This topic created in 3623 days ago, the information mentioned may be changed or developed.

    http://www.ibm.com/developerworks/cn/web/wa-nodejs-polling-app/

    看完教程,学习了很多,但有一处没有看懂

    angular.module('pollServices', ['ngResource']).
              factory('Poll', function($resource) {
                return $resource('polls/:pollId', {}, {
                  query: { method: 'GET', params: { pollId: 'polls' }, isArray: true }
                })
              });
    

    这是 restful 请求, 为何 params :是{ pollId: 'polls' }, polls 在这儿是什么意思?

    2 replies    2016-06-07 09:54:54 +08:00
    klesh
        1
    klesh  
       Jun 7, 2016
    代表 Poll.query({ polls: 123}) 会去请求 polls/123 这个 url
    CareiOS
        2
    CareiOS  
    OP
       Jun 7, 2016
    @klesh 那这儿我可以乱写,比如写成:
    ```
    params: { pollId: 'id' }
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3085 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 11:05 · PVG 19:05 · LAX 04:05 · JFK 07:05
    ♥ Do have faith in what you're doing.